I am quite new to C++ and so was wondering if you guys could help me.
I was going through a piece of code and saw a function underneath a template, like this:
MyClass
{
template<class TemplateClass>
void MyClass::myMethod(xyzType parameter1, xyzType parameter2)
{
xyzType var = xyzObject->createSomething(new TemplateClass(parameter1), parameter2);
}
};
My question is, why would someone do that? myMethod could very well have been created without the template. Is there an advantage of using a function with a template, and if yes, then what is the advantage? Also when should it be, and when should it not be used?
Any help is appreciated.. Thank You
Aucun commentaire:
Enregistrer un commentaire