Can we just have struct inheritence already?

Exil Exil at gmall.com
Thu Jun 13 14:32:55 UTC 2019


On Thursday, 13 June 2019 at 06:43:44 UTC, Manu wrote:
> This should obviously be a compile error:
>   struct A { int x; }
>   struct B : A { int y; }
>   B b;
>   A a = b; // <- obviously an error


It doesn't become so obvious when you can implicitly convert to 
the base type.

     A foo(ref A a) { return a; }

     B b;
     A a = foo(b);


More information about the Digitalmars-d mailing list