Can some one explain me a point in my following program The following program i wrote to understand what is meant by int * const * var;
#include "iostream"
using namespace std ;
int main(){
int a = 2;
int * const x = &a;
int * const * p = &x;
cout << **p;
return 0;
}
The output of this program is 2 .
My point of concern is p is pointer to a constant pointer to an int which is how i am using it , but i always studied that to store a pointer you need pointer to a pointer . How is this program working then . Should'nt i have used
int * const **P
as this would mean P could be containing address of some pointer .
I dont know why my code works :)
pis already a pointer to pointer. Just look at its declaration.