I'm struggling to figure out why in the output, r == 2 j == 3 k == 2
r == 10 j == 2 k == 3, why the second time r would be equal to 10. Can anyone tell me why?
void func9() {
cout << "func9() " << endl;
int doSomething( int &, int );
int j = 2;
int k = 2;
int r = j++;
cout << "r == " << r << " j == " << j << " k == " << k << endl;
r = doSomething(j, ++k);
cout << "r == " << r << " j == " << j << " k == " << k << endl;
}
int doSomething( int & f, int k ) {
int j = f+k++;
f--;
return(j+k);
}