Multiple Inheritance from two derived classes

后端 未结 5 1312
清酒与你
清酒与你 2020-11-30 08:55

I have an abstract base class which acts as an interface.

I have two \"sets\" of derived classes, which implement half of the abstract class. ( one \"set\" defines t

5条回答
  •  心在旅途
    2020-11-30 09:02

    You have to start thinking in the terms of what you are trying to model here.

    Public inheritance should only ever be used to model an "isa" relationship, e.g. a dog is a animal, a square is a shape, etc.

    Have a look at Scott Meyer's book Effective C++ for an excellent essay on what the various aspects of OO design should only ever be interpreted as.

    Edit: I forgot to say that while the answers so far provided are technically correct I don't think any of them address the issues of what you are trying to model and that is the crux of your problem!

    HTH

    cheers,

    Rob

提交回复
热议问题