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>

6th Jun 2017, 3:48 AM
Suleiman Mwacharo
Suleiman Mwacharo - avatar
7 Antworten
+ 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...
6th Jun 2017, 11:22 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
I am also using the keyword class or the keyword template I think it need to be there
6th Jun 2017, 4:02 AM
Raphaël Charozé
Raphaël Charozé - avatar
+ 1
Thanks... I have understood now
6th Jun 2017, 4:35 AM
Suleiman Mwacharo
Suleiman Mwacharo - avatar
0
i understood that template is mandatory in this code but what about the keyword class
6th Jun 2017, 4:10 AM
Suleiman Mwacharo
Suleiman Mwacharo - avatar
0
James what if we were just declaring a template function that is not included in any class
6th Jun 2017, 4:31 AM
Suleiman Mwacharo
Suleiman Mwacharo - avatar