Answer the question
In order to leave comments, you need to log in
Variable number of function parameters (variadic template), how to make recursion?
Greetings!
I want to make a function with a variable number of arguments, which would be called like this: functionName(param1, param2, paramN);
All parameters are of the same type, but their total number is unknown.
I am writing a template:
template<typename... Args>
void functionName(double arg1, Args ... args) {
....
return functionName(args...);
}
void functionName() {}
Answer the question
In order to leave comments, you need to log in
Instead of a variable number of arguments, you can use an array or some kind of container, in which to write all the values of these arguments.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question