Reputation: 359
I read in Lippman et al that there is no way to rebind a reference to a different object (p59)
It sees to me that the code below does just that and doesnt produce any error in VC Express 2010
Can someone pls explain to me what's happening.
Many Thanks,
Paolo
void demo()
{
int i = 5;
int k = 5;
int& ir1 = i;
int& ir2 = k;
ir2 = i;
}
void main() {
demo();
}
Upvotes: 0
Views: 77
Reputation: 206831
Your code isn't rebinding anything. It's just assigning a new value to what the ir2
reference is bound to.
Upvotes: 6