More information on Templates in C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

More information on Templates in C++

So, I've been understanding templates in C++, but one thing I don't understand is why you have to call a new template for each new function or class, isn't there a way for a global template??

8th Feb 2017, 3:57 AM
SoraKatadzuma
SoraKatadzuma - avatar
1 Answer
0
you have to have template <class d> over the class and that over every member function of the classes implementation as well so template <class d> void myClass<d>::myFunc(){} its just the way the syntax works.... nothing you can do about it. hooe this helps
19th Feb 2017, 7:53 PM
Michael Szczepanski
Michael Szczepanski - avatar