我有一个看起来像这样的函数:
bool generate_script (bool net, bool tv, bool phone,
std::string clientsID,
std::string password,
int index, std::string number,
std::string Iport, std::string sernoID,
std::string VoiP_number, std::string VoiP_pass,
std::string target, int slot, int port,
int onu, int extra, std::string IP, std::string MAC);
在我看来,它看起来很丑。处理这个问题的正确方法是什么?我应该创建几个具有不同数据类型(int、string 和 bool)的 vector 并将它们作为参数传递给这个函数吗?
最佳答案
如果所有这些参数都有意义相关,请将它们打包到一个结构中。
关于c++ - 将多个参数传递给函数的优雅方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24952190/