March 25, 2019
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)









March 25, 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@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)
>
>
>
>
>
>
>
>
>
>