Derive from interface

Daniel Kozak kozzi11 at gmail.com
Mon Mar 25 22:15:51 UTC 2019


It depends on what you want. But you can always use composition instead of
inheritance for B. I have been  using things like alias this, mixin and
ufcs to achive multiple iheritence and it works ok for me.

On Mon, Mar 25, 2019 at 10:40 PM Michelle Long via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> Since D does not support multiple inheritance, is there any way
> to effectively achieve this?
>
>
> class A;
> class B;
>
> class C : A, interface!B;
>
> Then it is as if I have done
>
>
> class A;
> interface iB;
> class B : iB;
>
> class C : A, iB;
>
> But I can then do
>
> C c = new B;
>
> (but since I can't make B inherit iB, this is impossible)
>
>
>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20190325/ccb02288/attachment.html>


More information about the Digitalmars-d-learn mailing list