Reputation: 927
My question is related to calling a function as well as decrement operator. The answer for the following code is 20 1 19 10 My question is that after "--m" the m should be 19 so it should send 19 and finally 19 should be print giving output 19 1 19 10 but why is m not changing even though there is "--m"?
void f(int a, double b){cout<< a--<< '\t'<< b<< endl;}
int g(double x, int y){ return (x / ++y);}
int main()
{
int m = 20, n = 10;
f(m, g(--m, n));
cout<< m<< '\t'<< n << endl;
return 0;
}
Upvotes: 0
Views: 52
Reputation: 73542
This is unspecified behavior. The C++ doesn't state the order of evaluation of parameters.
Upvotes: 3