Note that this is only a question of template syntax, not an object-oriented object-oriented polymorphism design. This example is a manufacture for this purpose.
Let's say I have a base class:
class A: public B
{
...
};
I use it ...
A a;
a.DoSomething();
What if I would like to do something like this to be able to generate A at compile time not only from B, but also from other classes. So that I can use it like this:
A<B> a;
a.doSomething();
A<C> ac;
ac.DoSomething();
Can I do something like this?
template <typename BASECLASS>
class A : public BASECLASS
{
...
};
Suppose my constructor had a parameter, and I knew that any template that I use for the hte base class has the same signature. If so, this is a * .h file, what do you do with a * .cpp file? Is it legal to initialize a constructor?
A::A(int param) : BASECLASS(param)
{
}
, - - ++, .