I have a problem with implicit casting, templates, and inheritance from template classes. The following is what I extracted from my project, I did not notice that some classes are even abstract, but this is irrelevant.
class A {};
class B : public A {};
template <typename T> class Base {};
class Derived : public Base<B> {};
int main() {
Derived d;
Base<A>* base = new Derived();
}
Basically, I have a base template class Basefrom which I get Derived : public Base<B>from. Then I have to attribute it to the most general form of Base, which is Base<A>.
I would think that I can carry an object from Base<B>to Base<A>, as it Bcomes from A. Am I doing something wrong or how can I do it implicitly? This is important because I need to accept all types of Derived classes in a method Baseas a parameter.
Thanks in advance.