简体   繁体   中英

Passing a list of arguments (C++)

I have lots of functions (it's actually an API) that go like this:

void func1(const funcData1& data, ...);
void func2(const funcData2& data, ...);

etc.

where funcData1 , funcData2 , etc. are only used for passing a list of arguments to the function. Every time a new function is added, a new funcData89 is added too. This is not the best solution, IMHO. So I am looking for a more generic way to pass them. Any ideas?

Thanks!

您可以查看可变参数或将参数作为集合传递:

void func (const funcData1& data, const std::list<Arg>& args);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM