Aug 4, 2013 at 4:41pm
It is due to the definition of the conditional operator and its priority.
The conditional operator is defined as
conditional-expression:
logical-or-expression
logical-or-expression ? expression : assignment-expression
The assignment operator has higher priority compared with the comma operator
So your expression is equivalent to
(( x > 10 && y > 10 ) ? ++x, ++y : --x ), --y;
Last edited on Aug 4, 2013 at 7:46pm
Aug 4, 2013 at 7:37pm
@vlad thanks again. I find that a bit bizzare though considering I parenthesized the condition before the ?.
Aug 4, 2013 at 7:47pm
In my example there was a typo. The condition should be enclosed in parentheses.:)
Aug 4, 2013 at 7:50pm
Hah, likewise! Thanks for the explanation :)