Newbie: copy, assignment of class instances

bearophile bearophileHUGS at lycos.com
Thu May 27 15:41:19 PDT 2010


Thank you Steven for your explanations, I have done similar things in C and D, but I didn't understand what you meant.

>A is always put first, that way, a pointer to a B can always be used as a pointer to an A.<

Are you sure C specs say doing this leads to defined behaviour?
(Recently from a discussion with Walter I have learnt that D follows exactly C specs regarding such defined/undefined things.)


> What I would like is a common-sense approach to inheritance for structs  
> that just does not allow virtual methods or interfaces, and which does not  
> cast implicitly to the base (explicit cast is OK).  I think some designs  
> would benefit greatly from this simple feature.  I think it's more tricky  
> than I've described, but I think with some diligence it can be done.

I have desired some form of inheritance in D structs (before the creation of alias this, that so far I have not used much). I think Walter will not love this idea, but you can think more about its details, and then you can post it in the main D newsgroup.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list