+ 2
The difference!
int x=3, y=2; x+=++x-y; //In Cpp x=6, but x=5 in Java; I just think why?
4 Answers
+ 1
java saves left side before evaluate right side
c++ do E1 = E1 + E2 but E1 expression is evaluated only one times
3 = 3 + ( (3+1) - 2 ) = 5
System.out.println(x);
https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.26.2
(x=3+1) - 2 = 2
4 = 4 + 2 = 6
cout<<x;
http://eel.is/c++draft/expr.ass
+ 1
I got it. thanks for your support, guys :)



