object oriented value type

Robert Fraser fraserofthenight at gmail.com
Fri Jun 29 10:52:47 PDT 2007


Ender KaShae Wrote:

> 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? 

C++ slices off subclass fields if assigned to a superclass type. If class Foo has a field x and class Bar, which extends Foo, has a field y, then:

Foo f = Bar();

will only store the value of x, not y.



More information about the Digitalmars-d mailing list