The "implemented with" relation

Frank Benoit keinfarbton at nospam.xyz
Fri Sep 29 00:36:54 PDT 2006


A "implemented with" relation in C++ is done with a private inheritance.
This is OK, because in C++ the public inheritance is not restricted with
this private inheritance (muliple inheritance).

But does a protected inheritance even make sense in a language without
multiple inheritance?

If I do this

class T : private D {
}

the functionality from Object is no more visible to a user of T (if they
are outside of the current module).
e.g. container can complain, they cannot access opEqual. Is this the
wanted behaviour? I don't think so.

To use a "implemented with" relation, one should better use mixins. But
there is a ctor/dtor integration missing. A mixin should be able to have
a this()/~this(), which are implicit called with the outer objects
ctor/dtor. A explicit call of the mixins ctor is also possible. A mixin
can also have a ctor with args: this( int ), which then has to be called
explicitly from the objects ctor, or a compiler error is given.

Please remove the inheritance protection and add the ctor/dtor
integration for mixins.



More information about the Digitalmars-d mailing list