R
Rahul
Hi Everyone,
I just tried the following code, in response to some post on
reference member variable and i'm not able to understand what exactly
is happening over here,
int main()
{
int a=5,b=6;
int &ar = a;
int &br = b;
printf("ar is %d and br is %d\n",ar,br); //prints 5 and
6
ar = br;
printf("ar is %d and br is %d\n",ar,br); //prints 6 and
6
printf("a is %d and b is %d\n",a,b); // prints 6 and
6, not sure how a's value got modifed
ar = 10;
printf("a is %d and b is %d\n",a,b); // prints 10 and
6
return(0);
}
Could anyone throw in some light, thanks in advance!!!
does ar=br copy the value of b into a?
I just tried the following code, in response to some post on
reference member variable and i'm not able to understand what exactly
is happening over here,
int main()
{
int a=5,b=6;
int &ar = a;
int &br = b;
printf("ar is %d and br is %d\n",ar,br); //prints 5 and
6
ar = br;
printf("ar is %d and br is %d\n",ar,br); //prints 6 and
6
printf("a is %d and b is %d\n",a,b); // prints 6 and
6, not sure how a's value got modifed
ar = 10;
printf("a is %d and b is %d\n",a,b); // prints 10 and
6
return(0);
}
Could anyone throw in some light, thanks in advance!!!
does ar=br copy the value of b into a?