I have three classes that inherit from both whirlyB and gameCreature. I am using all three sub classes in a collection of gameCreatures. Is there a way to use the inherited functionality from whirlyB. I am only given the choice of using gameCreature functions. What should I do to get the functionality of whirlyB?
I have three classes that inherit from both whirlyB and gameCreature . I am
Share
Here’s a silly idea, for the case where you’re stuck with one of the base pointers but are free to modify the classes. Suppose we have:
and suppose that you only have
Rock-pointers available. EditRockas follows:Now add to each derived class the following:
Now, given
Rock * r, you can sayHardPlace * h = r->get_other().I wouldn’t really call this good design, or even recommendable, but I think that’s a literal answer to your question.