While trying to understand the concept of variadic templates. I came across this example. This seems to be a minimalistics example for me.
void output() --------->function A
{ cout << "This is the resultsn"; }
template <typename T, typename ...P>
void output(T t, P ...p) ------->functionB
{
cout << t << ' ';
{
output(p...); ------>statement A
}
}
//Test it
int main()
{
output('5', 2);
retu(0);
}
Now the output of the above program is:
5 2 This is the results
Here are some questions that I had regarding this example:
1)What is statement A calling ? is it calling the function A ? But it only seems to call it once ?Also the method does not have any parameters in its signature ? How did I get 5 2 This is the results in the above example as the output
2)What does it mean when the author states that variadic classes are recursive and thus they require a base class
