Hi, I'm a bit confused on this pointer question, can anyone shed some light on this?
Please and thank you
int x = 10;
p = &x;
cout << p << endl; //should get address of x
cout << &x << endl; //address of x
cout << *(&x) << endl; //10
cout << &p << endl; //<--- this is the address of p
cout << *(&p) << endl; //address of x , but why is this the address of x??
&p -> get the address of the pointer p, hence making a pointer to the pointer.
*(&p) -> dereference that pointer to the pointer p, getting back the original pointer p.