Making inheritance less tedious

Bill Baxter dnewsgroup at billbaxter.com
Tue Feb 27 12:14:56 PST 2007


Michiel wrote:

> However, I understand your point. If a base class is changed, and you
> have no source-access to it, you still don't want to entirely break your
> subclass away from it. Maybe another type of relationship should be
> formally introduced for such situations. 'Is-kinda-like', or
> 'is-mutation-of' or something, which would allow suppressing parts of
> the public interface.
> 

Isn't that what interfaces and object composition are for?
If what you have isn't is-A, then like you said inheritance is probably 
not the relationship you're after.  Create a 
ThingsPeopleHaveIrrationalAttatchmentsTo interface and have both Pet and 
Aibo implement it.  Aibo might implement it internally using a Pet member.

In C++ you also have the option of private inheritance.  Does D have that?

Anyway, Aibo's eat electricity, so there's no problem here to begin 
with.  :-)



More information about the Digitalmars-d mailing list