Struct vs Class

Bill Baxter dnewsgroup at billbaxter.com
Sun Dec 10 20:31:35 PST 2006


Derek Parnell wrote:
> Have I got the difference between Class and Struct right? Have I missed
> anything?
> 
> Functionality              Class          Struct
> --------------------------------------------------
> Default instantiation  ::  Heap           Stack
> Constructor            ::  this()         void opCall()
> Destructor             ::  ~this()        None
> Argument passing       ::  by Reference   by Value
> Assignment             ::  Reference      Value
>                              bit copy        bit copy
> Inheritance            ::  Single         None
> Interfaces             ::  Multiple       None
> Order of data members  ::  Defined by     Defined by
>   in RAM                     compiler       coder
> -------------------------------------------------
> 
> 

Also you should include the new features for overloading opAssign and 
the implicit call of static opCall.  (I think there's some difference 
there for structs and classes, though I haven't looked at it too closely 
yet).

--bb


More information about the Digitalmars-d-learn mailing list