C/C++ Ternary Operator Precedence and Associativity
Although many sources incorrectly place the ternary- and assignment operators on two seperate levels, they in fact share the same precedence level. Note, however, the right-to-left associativity of both, which allows an unparenthesized ternary operation to be assigned to a variable.
If you would like to verify this yourself, take a look at the C++ standard. Alternatively run the following in a compiler of your choice:
You will find that, after running the above, both x and y are zero, which is consistent with
and not with
in which case x=5.
Questions, comments ==> info (at) (this domain)