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:

int x=0,y=0;
true?x:y=5;

You will find that, after running the above, both x and y are zero, which is consistent with

int x=0,y=0;
true?x:(y=5);

and not with

int x=0,y=0;
(true?x:y)=5;

in which case x=5.

Questions, comments ==> info (at) (this domain)

Other quick-reference sites:   db9-pinout.com | resistor-color-codes.com | hex-codes.com

Cheap NFL Jerseys Cheap NFL Jerseys goedkope air max online Basket Air Jordan 11 Christian Louboutin Outlet Cheap Jerseys Wholesale Jerseys Michael Kors Outlet Online Ray Ban Sunglasses Jerseys Wholesale Coach Outlet Store michael jordan air jordan 11 Coach Outlet Cheap NFL Jerseys Kate Spade Outlet Sale air max 90 pas cher junior Wholesale Jerseys Jerseys Cheap nba jerseys vegas Jerseys Wholesale China