0
Hi, guys i wanted to ask is it really a must to add the keyword class when declaring a function template or can any word be used
template <class T>
5 Answers
+ 2
A template in general allows the user to use any data type needed by a user for a function.
The best way to achieve this is to use a user-defined data type and change it for the use at compile time...
This can only be achieved if one uses a class, which allows user to define a user-defined data type.
Thus, class is required.
But, we can use typename instead of class, as it helps achieve the same thing...
+ 1
I am also using the keyword class or the keyword template
I think it need to be there
+ 1
Thanks... I have understood now
0
i understood that template is mandatory in this code but what about the keyword class
0
James what if we were just declaring a template function that is not included in any class