int main()
{
int ival=12 , ival2 = 14;
int &ref=ival;
ref = ival2;
cout<<ref;
return 0;
}
That code shows an o/p as 14? How is it possible ? i thought references were not reassignable ?
1 more thing- do references occupy seperate spaces in memory like pointers ?
Consider this :
int ival;
int &ref = ival;
cout<<sizeof(ref);
In this case is the 'ref' replaced by ival ? or is it that ref occupies 4 bytes in the memory like ival ?
Thank ya