Why templates are used???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why templates are used????

4th Dec 2016, 7:15 AM
Mohammed Fazil
Mohammed Fazil - avatar
3 Answers
+ 2
If you need a function that calculates the average of 3 values, you'll have to make both "Average(int a,b,c)" and "Average(float a,b,c)", and so for every numeric type. Or, you can instead make "Average T a,b,c)" and use it for everything.
4th Dec 2016, 7:46 AM
Sandberg
+ 1
simple things first it makes your coding very less as possible by making a generic structure shown by Sandberg on the below comment !!
4th Dec 2016, 7:49 AM
MRINAL DUTTA
MRINAL DUTTA - avatar
0
👍
4th Dec 2016, 7:51 AM
Mohammed Fazil
Mohammed Fazil - avatar