Why can't I inherit (extend) structs?

Mike Parker aldacron71 at yahoo.com
Tue Oct 10 09:59:56 PDT 2006

Lionello Lunesu wrote:
> I like the definition of 'struct' in D: simple aggregations of data. But 
> is there currently a way to extend a struct? Apart from composition, 
> that is. I'd like to do something like this:
> struct X {
>   int x;
> }
> struct Z : X {
>   int z;
> }
> Would this feature add complications that I fail to see?
> It's not a big deal, since I can use composition, but I'll have to name 
> a member for the first struct and repeatedly write it.. And I'm lazy :S

Once you start extending structs, you'll need the same bookkeeping 
overhead required for classes. That eliminates the current distinction 
between them.

More information about the Digitalmars-d-learn mailing list