+ 1
Can anyone explains about Templates?
in c++ how can we use it ?
1 Réponse
+ 5
Templates are used to reduce code in your program.
Example :
Suppose you want your program to have functions that take two arguments , add number and return the sum.
Now you have to define same function multiple time that takes different argument (one that takes two int , one for float and so on).
With templates you can write code once (i.e define function only once) and use it for different arguments.