Assume we have this piece of code:
#include <iostream>
int foo(int &x, int& y)
{
return x * y;
}
int main()
{
int x = 10;
int y = 5;
std::cout << foo(++x, x+=y);
}
Could you please explain why this expression gives output 256? Which is the exact order of parameters-assignment, or it is compiler-defined.Even if we consider both cases of evaluation order of parameters if first case(when x++ evaluated before x+=y) the logical output should be 176, in second case 240. I really do not understand the logic of resulted output.