Can anyone explains about Templates? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Can anyone explains about Templates?

in c++ how can we use it ?

20th Jun 2018, 7:13 AM
Sanjaykrishna Hegade šŸ‡®šŸ‡³
Sanjaykrishna Hegade šŸ‡®šŸ‡³ - avatar
1 Resposta
+ 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.
20th Jun 2018, 9:24 AM
Meet Mehta
Meet Mehta - avatar