gpt4 book ai didi

c++ - 将多个参数传递给函数的优雅方式

转载 作者:IT老高 更新时间:2023-10-28 14:01:35 33 4
gpt4 key购买 nike

我有一个看起来像这样的函数:

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/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com