I read the following statement in the book:
n = ((i++) > (j)?(i++):(j));
The book claims that assuming that i> j, n has an unexpected value, and I doubled.
I do not understand why n has the expected value after this statement.
I read a lot of examples about undefined behavior, so here is my theory (and not an explanation of the book, as not) and tell me if I am correct:
at first, (i ++)> (j) is evaluated, and I may or may not be increased though.
Assuming i> n, (i ++) should be estimated. We do not know whether I have been enlarged or not , therefore, why all this statement is undefined. we are not sure whether I or I will refund +1.
Now the problem, suggesting that my theory is correct - Why do not we know I have still increased or have not been ? If this line of code were written as an if statement, I am sure that I will have to increase it earlier. So why is the connection if it is different?
Thanks.
source share