think of a reference as an alias or nickname. Its the same guy, just going by a different name.
think of a pointer as an array index into the great big array in the sky that we call 'memory'.
you don't have a reference. this is a reference:
1 2 3 4
|
int joebob = 13;
int &joe = joebob; //IMPORTANT: THE & IS ON THE NEW VARIABLE NOT THE OLD.
joe = 10;
cout << joebob << endl;
|
what you have is the address of a pointer, which is a 2-d array or a ** or similar ideas.
you said
int * ip = new int;
do something with &ip; //see the & on existing variable?
which is the address of the address of the integer pointed to by ip.
or maybe more clearly,
the location in memory of the variable that stores the location in memory of the integer.
That said, pointers and references are very similar in some ways. There is some overlap in behavior ... both of them can, with the right syntax, modify another variable. That is, a pointer can be used to approximate a reference. You will just need some practice to understand this, but if you think about it, a reference is the same object, a pointer can point to the other object, so they can both access the other object as if they were it.