struct vs. class

David B. Held dheld at codelogicconsulting.com
Mon May 28 15:42:09 PDT 2007


Martin wrote:
> Inspired by the recent discussion about iterator structs/classes I wanted
> to ask - what's the design rationale behind having both structs and classes?
> [...]

The most important difference is that structs have value semantics and 
classes have reference semantics.  There are very good reasons to have 
both, and unifying them would be as wrong as taking away pointers or 
taking away stack objects.

Dave



More information about the Digitalmars-d mailing list