The one advantage of using class T in c++ is to reduce the time to redefine data types in a function, if those data types are defined in other function, for example, in int main.
template <class T>
void showabs(T number)
{
if (number < 0 )
number = -number;
cout << number << endl;
return 0;
}
int main()
{
int num1 = -4;
float num2 = -4.23f;
showabs(num1);
showabs(num2);
return 0;
}
So in this case, without class T, for each data type, we have to add its corresponding data-type condition, that is, another set of if statement for int, and another one for float.
Am I correct?