J
John Black
Hi,
In the following code,
void func(int b, int h){
int dummy;
int& i1 = dummy;
int& i2 = dummy;
if ( <some condition>){
i1 = b;
i2 = h;
}
else{
i1 = h;
i2 = b;
}
< some operations>
}
I find that even I decalre i1 and i2 as 2 variable, just because
their initialization point to same variable, their addresses equal! The
statment following actually all operate on same i1/i2.
Is this as expected?
Thanks!
In the following code,
void func(int b, int h){
int dummy;
int& i1 = dummy;
int& i2 = dummy;
if ( <some condition>){
i1 = b;
i2 = h;
}
else{
i1 = h;
i2 = b;
}
< some operations>
}
I find that even I decalre i1 and i2 as 2 variable, just because
their initialization point to same variable, their addresses equal! The
statment following actually all operate on same i1/i2.
Is this as expected?
Thanks!