In C #, your code is well defined and equivalent to the following:
a = a - (b = b - (a = a - (b = b + (b = b - a))));
The most internal assignments are not relevant here, because the assigned value is never used until the variable is reassigned. This code has the same effect:
a = a - (b = b - (a - (b + (b - a))));
This is about the same as:
a = a - (b = (b * 3) - (a * 2));
Or even simpler:
b = (b * 3) - (a * 2); a -= b;
However, in C ++, your code gives undefined behavior. There is no guarantee what she will do.
source share