0
int **p; what is the meaning of this code?
whats that mean?
6 Respostas
+ 3
It is a pointer to a pointer.
+ 3
It is multiple indirection.
When a pointer points to other pointer , it is called multiple indirection.
for example
int x = 3;
int *p1 = &x;
int **p2 = &p1;
int ***p3 = &p2;
Access the value of variable by dereferencing pointer.
cout<<x<<endl;
cout<<*p1<<endl;
cout<<**p2<<endl;
cout<<***p3<<endl;
+ 3
it is a pointer to pointer where a pointer is pointing to the address that us being pointed by another pointer. for example ,
int x = 5;
int *p=&5;
int *q=&p;
+ 2
int main(){
int p = 8;
int q = 7;
int *pp = &p;
int *qq = &q;
int **pq = &pp;
cout << **pq << endl;
pq = &qq;
cout << **pq << endl;
return 0;
}
Output:
8
7
0
or a pointer to 2D array.
a[][] can also be represented as **a
- 3
Its a pointer ! It stores address of a particular variable unlike normal variable that stores value