Tomasz Kasperczyk Tomasz Kasperczyk - 5 months ago 14
C++ Question

Elegant way to pass multiple arguments to a function

I've got a function which looks like this:

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);

In my opinion it looks ugly. What is the proper way of handling this problem? Should I create few vectors with different data types (int, string and bool) and pass them as arguments to this function?

Answer Source

If all these parameters are meaningfully related, pack them in a structure.