Is there a way to override a function returning a templated entity with different constructors in C++?
template<T> class A {
virtual shared_ptr<T> createEntity (a)
return make_shared<T>(a);
}
class E
{
int a,b;
E (int x, int y) : a(x), b(y);
}
class B : public A<E> {
int b;
shared_ptr<E> createEntity (a) override
return make_shared<E>(a,b);
}
The standard constructor of most Entities would require only one variable, whereas entities of other classes need more than one variable to be constructed. Can this be achieved without conditional compilation?
Edit: Other Entities implement their constructor with only one variable "a", so I basically want to use A::createEntity (a) in most cases and want to use B::createEntitiy in special cases.