I have 3 Questions:
In C/C++, variables basically hold an address that points to a memory location where the value is held.
For example:
int myVar = 5;
Here, myVar contains the address that points to a memory location that contains 5. If I change the variable value:
myVar = 10;
The memory address stays the same, but the value is overwritten.
- Is it possible to change what address myVar holds? (I am not referring to pointers *, just normal variables)
How about for object variables:
class Box {. . .}
Box myBox;
In the above example, myBox variable basically holds the address to a location in memory that contains the object.
Can someone change the address myBox references too? (Again, I am not referring to pointers *, just normal variables).
Does a normal variable hold a constant address in memory for the life of the program?
Thank you guys for your time and understanding!