object oriented value type

Ender KaShae astrothayne at gmail.com
Fri Jun 29 07:54:22 PDT 2007


Robert Fraser Wrote:

> What's the point? There's no way to refer to a subtype by the supertype (since the compiler wouldn't know what size the struct would be), so the only OO feature you'd get is mere aggregation, which should be explicit anyway.

Then how does c++ do it? 
 
> Ender KaShae Wrote:
> 
> >   But what about when you need a type that passes by value and supports inheritance, I don't think that the structs necessarily need to be changed, rather I think that a new type should be created as a combination of a struct and a class.  This would be particularly useful in inheriting from primitave types.  Another example is having a mixedFraction inherit from fraction.
> 
maybe a copy constructer and assignment overloading for classes would solve the problem, though there should be a keyword (say passbyvalue) that autamates the constructor the way c++ does.



More information about the Digitalmars-d mailing list