Where is the class assigned when stored in the structure?

I read a thread (which included Mark Gravell and John Skeet) that mentioned that the structure is in the class, this structure is stored on the heap, like a class.

What if the class is a member of the structure? Where is the class assigned?

thanks

+3
source share
2 answers

If the class is a member of the structure, then only the link is stored in the structure . (i.e. 32/64-bit instance address). A class instance is always on the heap.

+12
source

Still on the heap. The structure will contain only a reference to an instance of the class (for example, a pointer).

+3
source

Source: https://habr.com/ru/post/1704777/


All Articles