I have a base class A
and a few derived classes B
, C
and D
, that all have a method DoSomething()
, which is virtual in the base class method (it's implemented in all sub classes as well as in the base class).
I have a problem, that the derived class B uses the method from the base class A. This may be the result of bad design, but I do not see the problem as the implementation is pretty straight forward.
An object of class B that is created in the following
A* a = new B();
If I call the method DoSomething()
for this object, the method of the base class is used:
a->DoSomething(); //Results in Base class method being called.
But I expect/want that the method of class B is used. Can you tell me what's wrong?