Why are structs and classes so different?

bauss jj_1337 at live.dk
Mon May 16 07:34:45 UTC 2022


On Sunday, 15 May 2022 at 15:59:17 UTC, Alain De Vos wrote:
> Can i summarize ,
> structs are value-objects which live on the stack.
> class instances are reference objects which live on the heap.

But that's not entirely true as you can allocate a struct on the 
heap as well.

The real difference is inheritance and polymorphism, not 
allocation and where the memory lives.


More information about the Digitalmars-d-learn mailing list