general questions on reference types versus value types...

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 30 20:42:36 PST 2014


Is it correct to say that D reference types (classes, dynamic 
arrays, etc.) are always allocated on the heap; whereas D value 
types (structs, static arrays, etc.) are always allocated on the 
stack?  Or is this a gross oversimplification?

Because can't structures contain classes and classes contain 
structures?
If so, how should one thinks about these hybrid types?  Does the 
outermost type take precedent over what ever it contains?

Can't resist this. Maybe I should just create a play code, but 
could a Structure contain a class that contained a structure that 
contained a class that...  Not sure why one would ever need to, 
so just a theoretical question.

thanks.





More information about the Digitalmars-d-learn mailing list