May 2012
Intermediate to advanced
679 pages
16h 56m
English
It is possible to have functions with variable number of arguments in C++. We have already seen function printf(). A typical call looks like
printf(“%d%d", i, j);
This example has a format string followed by two parameters. There could have been even three or four parameters. This is an excellent example of function with variable arguments.
We can have our own function of this type. In the declaration, argument list must have few (at least one) leading parameters. It is followed by an ellipsis (…). It indicates to the compiler that the present function may have variable number of arguments. While calling such a function, argument list must have leading arguments as defined. It can have any number of arguments ...
Read now
Unlock full access