Why are structs and classes so different?
forkit
forkit at gmail.com
Mon May 16 00:54:26 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.
the real difference, is that structs, being value types, are
passed by value, and classes, being reference types, are passed
by reference.
this is the most important difference to be aware of.
where they live in memory should be less of the programmers
concern, and more an implementation issue (although some
programmers will of course consider this as well).
btw. where does a struct, inside a class live?
More information about the Digitalmars-d-learn
mailing list