+ 3

What is the main difference between function and class template?

Please explain anyone!

13th Jun 2016, 4:59 PM
Utpal Kumar
Utpal Kumar - avatar
4 Réponses
+ 4
there is no diference. they are just diferent things you need to learn
13th Jun 2016, 6:27 PM
Klodian Lula
Klodian Lula - avatar
+ 4
The difference is that by using template functions and hence generic parameters , you do not need to write seperate functions for using the same rules for different data types but one template function can be used for different data types. e.g int sum ( int a, int b) or double sum( double a, double b) can be replaced by one template function T sum( T a, T b) having previously defined the template class T.
18th Jun 2016, 9:10 PM
Srinivas Mandgi
Srinivas Mandgi - avatar
+ 1
Thanks!
14th Jun 2016, 10:04 PM
Utpal Kumar
Utpal Kumar - avatar
0
templates provides use of generic(auto casting of data types as per requirement ) parameters, whereas functions have to be defined with a specific parameters .So,its better to use templates.
1st Jul 2016, 7:45 PM
Akash Roy
Akash Roy - avatar