Why can't I inherit (extend) structs?

Derek Parnell derek at psyc.ward
Mon Oct 16 14:06:37 PDT 2006


On Mon, 16 Oct 2006 18:49:20 +0200, Johan Granberg wrote:

> Derek Parnell wrote:
>> And I'd go so far as to say that the term 'inheritance' is a bit strong.
>> Maybe just 'derivation' as we would be deriving a new struct definition
>> from existing definitions, but there is no implied linkage between them at
>> runtime. 
> 
> If it is just derived from that is wanted wouldn't it bee easier with a 
> syntax like this.
> 
> struct foo
> {
> 	int b;
> 	int c;
> }
> struct bar
> {
> 	int a
> 	include foo;
> 	int d
> }
> 
> the struct bar would now have four fields (a,b,c,d)
> 
> this way their is no way to misunderstand it for inheritance and if one 
> want a foo* one can always take the addres of the first element.

Hey ... not bad. 

-- 
Derek Parnell
Melbourne, Australia
"Down with mediocrity!"



More information about the Digitalmars-d-learn mailing list