What does templates used for? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What does templates used for?

i mean their programming and practical significance in cases. can you write?

7th Feb 2017, 7:20 PM
GeekyShacklebolt
GeekyShacklebolt - avatar
1 Answer
0
Templates are used for writing same code for different types of objects. For example, if you create a template function for printing. Then that function can be called irrespective of the datatypes of the arguments. Note: Templates are compile time only. Compiler creates required functions based on the type of arguments in the format of template function, at the time of compilation.
8th Feb 2017, 4:25 AM
Chidvilas Yerramsetti
Chidvilas Yerramsetti - avatar