I'm revising C++ after a while, so please bear my curiosity :). Let's suppose we have a function that uses a template as follows:
template<typename T>
void print_array(T numbers[], T n)
{
//some code
}
What's the point of trying to define more template parameters, i.e.
template<typename T, typename Z> //2nd param Z
void print_array(T numbers[], Z n)
{
//some code
}
If it yields the same exact results/behavior?
Also from my understanding of templates, is that they were introduced to basically allow you to use a function for different inputs regardless of the parameter data types or even the function return type itself. As a matter of fact, even T print_array(T numbers[], T n)
works, albeit there was a warning regarding no return.
So what is even the point of function overloading then if templates are basically a way to handle various parameters and types regardless how the function is called?