We recently learned pointers in my college c++ class, and I just have a bit of a technical question, because when I am speaking about pointers, I want to make sure what I am saying makes sense.
So, a pointer stores a memory address for something like a variable or object. But, when you dereference that variable to edit the value AT that address, behind the scenes is that really accessing and editing the value stored in the RAM at that location, or is it accessing the variable from that memory location and then just changing it's value. Or is it one in the same? I hope that makes sense.
In other words, would it make more sense to say "Editing the dereferenced pointer changes the value at that memory location" or "Editing the dereferenced pointer changes the variable connected to that location". Or am I just overthinking this, and those statements are really one in the same because editing the value at that memory location also edits the variable at the same time because that's where the variable gets the data anyways?
In this code:
int *p = new int;
*p = 5;
the value that p
points to does not have a name. There is no "variable" there, just a memory location. So it is probably better to just say "the value at that location has been set to 5".