I'm having an inheritance problem. My mom says she just won't leave me
her Three Stooges DVD collection when she's gone. Okay, just a bit of
OO levity. Here's the real problem:
We have AbsBase1, AbsDerived1, AbsBase2, ConcreteBase, and
ConcreteDerived.
The following inheritance hierarchy applies (arrows point to base
classes):
AbsBase1<---AbsBase2<---ConcreteDerived
ConcreteBase<---ConcreteDerived
Note that ConcreteDerived is the same class type on both lines.
AbsBase1 has an abstract method called doThis(). ConcreteBase
implements a virtual doThis(). ConcreteDerived has no doThis() method.
This causes a compiler error saying that ConcreteDerived needs to
implement doThis(). I was surprised it didn't compile, since I figured
that ConcreteBase's doThis() implementation would serve as the
ConcreteDerived implementation. So we want to do something like this:
Does this compiler error seem correct? If so, what do I need to do to
get this design to work? Namely, what do I need to do to be able to
get doThis() to run polymorphically through AbsBase1 given an object of
type ConcreteDerived?
AbsBase1* myAbsBase1 = new ConcreteDerived();
myAbsBase1->doThis();
Thanks for any input!
Ken