Hi guys.
I need some clarification.
I have the following code segment:
to which the output is:Code:void Swap(Number& num1, Number& num2)
{
cout<<"Before swap:"<<num1<<" "<<num2<<endl;
Number& temp=num1;
num1=num2;
num2=temp;
cout<<"After swap:"<<num1<<" "<<num2<<endl;
}
int main()
{
Int n1(13), n2(11);
Swap(n1,n2);
cout<<n1<<" "<<n2;
}
that seems confusing.Code:Before swap:13 11
After swap:13 11
13 11
why doesn't Swap() swap the two Numbers?