If a template type can take any data type, why would we need multiple template types? Why not just make one template type and use it for everything? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

If a template type can take any data type, why would we need multiple template types? Why not just make one template type and use it for everything?

3rd Jan 2016, 6:26 PM
Taylor Street
Taylor Street - avatar
1 Answer
+ 3
cuz one templatetype only can be on Type at one time. So it's impossible that T is an int and a double. Next time you use the function T could be a char (but not an int at the same time)
11th Apr 2016, 11:04 AM
david_hil