I am having issue with dereferencing pointers
int x = 12;
int* y = &x;
int* &a = y;//This does work
int* &b = &x;//This does not work
Doesn't y
and &x
contain the same type of values / same value.
Can someone tell me what does int*& a
actually represents.
Edit:1
Sorry, I did not realize that such a simple code would yield two different result in c
and in c++
. In c
this line int*& a = y
is simply a mistake. However, in c++
, the code gives the error as I have shown.
Edit:2
int *&a = y; //compiles in g++ 7.3.0 ubuntu, but not in gcc 7.3.0
int *&b = &x; //it simply throws error in g++ and gcc