In the first code both of the printings are same, so as far as I understand the variables( a and b) share the same memory location.But in the second one it gives an error, what is the difference?
Also how (int &a = b )work? Arent we assigning the memory location to an integer by writing int &a = b?
int b = 9;
int &a = b;
cout<< &a << endl;
cout<< &b << endl;
int b = 9;
int a = 5;
&a = &b;
cout<< &a << endl;
cout<< &b << endl;