Address of..pointer

Hello,

If you want to access the address of a pointer, i.e. the address where the pointer is stored (and not the address the pointer stores!). Is this the correct way of doing it?

1
2
3
4
int d = 10;
int* e = &d;
cout << &e << endl << &d; //returns the address where e pointer is stored and the address where d is stored
cout << e << endl; //returns the address that the e pointer holds, i.e. the address of the d variable. 
To my knowledge, yes.
(But it won’t work that way if you ‘cout’ a char* - that because std::cout has been overloaded to display the C-style string, in that case.)
Last edited on
Line 3 shows the address of e and d. That e holds the address of d isn't relevant at that point.
But aren't my comments in the code correct?
yea they are correct
Topic archived. No new replies allowed.