有人认为使用类或结构传递参数有好处吗?
喜欢而不是
f(int,float,string)
有
f(Args)
其中Args是struct有int,float,string会员.
Args
struct
int
float
string
Advantage很容易创建多个默认参数,并且在添加新参数时不必更改函数签名.
c++ struct function
c++ ×1
function ×1
struct ×1