+ 21
Explain this question please? Wht happened in this program explain please .
6 Answers
+ 5
Because function x is called with same variable in position of both arguments, inside function variables a and b share same memory location. You can see that by adding test to function x:
int x(int &a, int &b)
{
if(&a==&b) cout<<"Same address"<<endl;
a=3;
b=4;
return a+b;
}
So first (a=3) both get value 3 and then (b=4) both get value 4.
+ 3
This question has been asked before and read comments.
checkout
https://www.sololearn.com/Discuss/2307927/?ref=app
+ 1
comments are pretty great:))