Can we just have struct inheritence already?
Manu
turkeyman at gmail.com
Thu Jun 13 22:13:51 UTC 2019
On Thu, Jun 13, 2019 at 7:35 AM Exil via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> 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);
So don't implicitly convert to the base type?
B extends A, but I don't think it's a kind of A as for polymorphic classes.
More information about the Digitalmars-d
mailing list