c++ - What does a pointer to a pointer mean? -
i have seen c++ programs pointer pointer variable i.e **i. mean , why used. cant use single pointer instead of that. difference between single pointer , pointer pointer. please explain each step. thank you.
variables take space store. space taken memory. suppose stack (memory) starts @ 0x12 34 56 78
and have integer a
value 4
:
int = 4;
your memory might like:
0x12 34 56 78: 0x00 00 00 04 (a)
now suppose have pointer a
:
int = 4; int* p = &a;
your memory like:
0x12 34 56 78: 0x00 00 00 04 (a) 0x12 34 56 7c: 0x12 34 56 78 (p)
now suppose have pointer p
:
int = 4; int* p = &a; int** q = &p;
your memory like:
0x12 34 56 78: 0x00 00 00 04 (a) 0x12 34 56 7c: 0x12 34 56 78 (p) 0x12 34 56 80: 0x12 34 56 7c (q)
you can q
p
a
following addresses. pointers layer of indirection: specify is, not is.
Comments
Post a Comment