I wonder if it is possible to retrieve the number of arguments of a function variable in C++. It is necessarily, otherwise how would the class std:: vector with its methods assign () and resize ().
I wonder if it is possible to retrieve the number of arguments of a function variable in C++. It is necessarily, otherwise how would the class std:: vector with its methods assign () and resize ().
When a function is declared, the data-type and number of the passed arguments are usually fixed at compile time. The general format for declaring the function remains the same as before except the data type passed as arguments in functions are in the same order in which it is defined in function.
These are default settings, for example:
Code:void function (int x = 1, int y = 0);
() function will call the function with parameters (1.0) and function (10) with (10, 0).
To use a function with variable number of arguments, or more precisely, a function without a set number of arguments, you would use the cstdarg header file. C++ Variable argument functions are useful wherever we are not sure about the number of parameters to be passed. Not all the compilers have the ability to decipher variable arguments.
Bookmarks