No, because you really have two base classes that don't know each other.
Italk parent
/ \ / \
| |
+ --------- +
|
Child
If Parent and Italk had two variables named i, there would be two instances of "i", ITalk :: i and Parent :: i. In order to access them, you will need to fully determine which one you need.
The same goes for methods, lChild has two methods called SayHi, and you need to figure out which one you have in mind when calling SayHi, since multiple inheritance makes it ambiguous.
Do you have parent SayHi
lChild->Parent::SayHi();
and Italk SayHi:
lChild->ITalk::SayHi();
The latter is pure virtual and because its abstraction must be redefined locally in Child. To satisfy this, you need to define
Child::SayHi();
What Parent :: SayHi () now hides when SayHi is called without looking at its class:
lChild->SayHi()
Of course Child :: SayHi () can call Parent :: SayHi ():
void Child::SayHi() { Parent::SayHi(); }
which will help solve your problem.
Doug T.
source share