#import<iostream>
using namespace std;
int main()
{
    //trying to test pointers & reference
    int x = 5;
    int y = 6;
    int *p;
    p = &y;
    *p = 10;
    int &r = x;
    cout<<"X reference\n"<<&r<<"\n"<<"value:"<<r<<"\n";
    r=y;
    cout<<"Y reference\n"<<&r<<"\n"<<"value:"<<r<<"\n";
}
In this code, I have assigned &r to x at first and then I have assigned r to y.
- What is the difference between assigning & r=x and r=y? Kindly help me out.
 
     
    