Say I have two classes A and B. I want A to have a templated function "makeObject ()", which makes a new object of the given class template-type and stores it internally.
Is the below correct?
Classes + Functions:
Is the below correct?
Code:
A a; a.createObject<B>();
Code:
class A
{
template<typename Tclass>
unsigned int createObject();
}
template<typename Tclass>
unsigned int A::createObject()
{
Tclass var = new Tclass();
return 0;
}
class B {};
Comment