struct vs. class

Martin m_dot_hinsch at rug.nl
Mon May 28 13:27:02 PDT 2007


Inspired by the recent discussion about iterator structs/classes I wanted to ask - what's the design rationale behind having both structs and classes? In C++ the necessity was given by backwards compatibility but that doesn't apply to D of course. 
The only principal differences I can see (I'm not a D programmer (yet), so please correct me if I'm wrong) are a) that structs don't contain run-time meta information (a pointer to a vtable or however that works) and b) that struct variables are statically allocated as opposed to class variables which always seem to be pointers into dynamic memory.
Somehow this looks really unorthogonal to me. Especially b) I find strange, can somebody explain the reason for this?

cheers
Martin



More information about the Digitalmars-d mailing list