+ 3
What is the main difference between function and class template?
Please explain anyone!
4 Réponses
+ 4
there is no diference. they are just diferent things you need to learn
+ 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.
+ 1
Thanks!
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.