Elegant way to pass multiple arguments to a function

前端 未结 6 1604
轮回少年
轮回少年 2020-12-13 05:52

I\'ve got a function which looks like this:

bool generate_script (bool net, bool tv, bool phone,
                        std::string clientsID,
                      


        
6条回答
  •  佛祖请我去吃肉
    2020-12-13 06:41

    A bit late here, but since nobody has done it yet, I'd like to point out an obvious aspect of the issue: to me, a function which takes so many arguments is likely to do a lot of computation, so consider the possibility of decomposing it in smaller functions as a first step.

    This should help you structuring your data.

提交回复
热议问题