Then why does it even exist? Im really confused. This is what it says in my book:
You can define a function so that it allows any number of arguments to be passed to it. You
indicate that a variable number of arguments can be supplied by placing an ellipsis (which is three
periods, ...) at the end of the parameter list in the function definition. For example:
1 2 3 4
|
int sumValues(int first,...)
{
//Code for the function
}
|
There must be at least one ordinary parameter, but you can have more. The ellipsis must always be
placed at the end of the parameter list.
Obviously, there is no information about the type or number of arguments in the variable list, so
your code must figure out what is passed to the function when it is called. The C++ library defines va_start, va_arg, and va_end macros in the cstdarg header to help you do this. It’s easiest to
show how these are used with an example.
I dont get why you even need them and how does it make your life easier. Im really confused. Can anyone provide a better explanation?