I have a question that I don't figure out about object. does making a object in c++ create a piece memory where all the data are stored inside that memory?
Asked
Active
Viewed 120 times
-2
-
I think it has been answered here: https://stackoverflow.com/questions/1632600/memory-layout-c-objects – Jose Mar 27 '20 at 12:31
-
How else might it work? – john Mar 27 '20 at 12:32
-
memory is not "created" on the fly (that would be actually quite cool) but allocated – 463035818_is_not_an_ai Mar 27 '20 at 12:43
-
Is human being just a piece of chemical elements in life? – Slava Mar 27 '20 at 12:53
1 Answers
0
Proper term is "memory location". An object may have memory location that can be described by an element of single primitive type or a sequence of elements. An object have "storage". Neither term refers to any particular representation in physical memory, it can be an abstraction, a range of RAM or cache storage units or a CPU register. A statically defined constexpr object might not have a memory location at all, but will have storage. Difference between storage and memory location is that latter can be adressed by other, external in relation to this object, means, e.g. by dereferencing pointer, by passing a reference to a function, by pointer arythmetics within range of an array of objects, etc.

Swift - Friday Pie
- 12,777
- 2
- 19
- 42