user696807
user696807

Reputation: 1

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!

Upvotes: 0

Views: 598

Answers (1)

Luchian Grigore
Luchian Grigore

Reputation: 258618

You can either look into variadic arguments or pass the parameters as a collection:

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

Upvotes: 2

Related Questions