This is different question from this one, as here I'm using object type struct
, instead of a value 23...
.
I'm reading this chapter on pointers and it states the following:
The address of a variable can be obtained by preceding the name of a variable with an ampersand sign (&), known as address-of operator. For example:
MyStruct* myvar = new MyStruct();
&myvar; // what is this address?
Is my understanding correct that it's the address of an object new MyStruct()
, not the variable itself? I don't yet have good understanding of how variables (not objects they reference) are stored, and it's very likely that they are not used at all when program is compiled.