I don't know why i=2 in the code below. Can someone explain how it became like that?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
#include <cstdarg>
usingnamespace std;
int calculate(int &val, int arg)
{
val *= arg;
return arg;
}
int main()
{
int i = 1;
int j = calculate(i,2); // because i=1, hence j=calculate(1,2) which makes j=2, but why is i=2 as well?
cout << i << j;
return 0;
}