My understanding is that a reference is basically a pointer with a value that doesn't change, and is always dereferenced. So if I have the code
int& thisIsAReference = someVariable;
Then basically a pointer is created to the location of someVariable
, and that pointer can never point to another location and is always dereferenced.
But that seems to be the same thing as a variable. As I understand it a variable refers to a particular memory location, can't refer to a different memory location, and implicitly refers to the value at a location rather than the location itself.
So, other than the differing syntax of declaration, is there any difference between thisIsAReference
and someVariable
?