Archived

This topic is now archived and is closed to further replies.

Daishim

Passing n variables?

Recommended Posts

Yes. This is how printf and similar functions work. They are defined something like:

void func(somevariable, ...);

The "..." is actually what you type and not just me being lazy. Then you can use va_start(), va_end(), and va_arg() to get the extra parameters. Of course, this is actually C. I''m not sure if C++ has it''s own method but since C++ >= C, you can use these functions.

Share this post


Link to post
Share on other sites
C++ can use stdargs/varargs as jaxson described.

Useful for truly variable parameter lists.

For most things though, where there''s some variability to parameters, but not too much, you are better off just using C++''s polymorphism and creating multiple methods, or using methods with parameter defaults.



Share this post


Link to post
Share on other sites