Operators | Associativity |
---|---|
( ) [ ] . (member) -> (pointer member) ++ (post) -- (post) | left to right |
(Unary) + (Unary) - ! ~ ++ (pre) -- (pre) & (referenec) * (de-reference) (typecast) sizeof(..) | right to left |
* / % | left to right |
+ - | left to right |
>> << | left to right |
< <= > >= | left to right |
== != | left to right |
& | left to right |
^ | left to right |
| | left to right |
&& | left to right |
|| | left to right |
?: | right to left |
= += -= *= /= %= >>= <<= &= ^= |= | right to left |
, | left to right |
Do not try to memorize the whole table....
Memorize the
most common order:
(1)
*, /, %
before
+, -
before
&&, ||.
(2)
Assignment operators has
very low priority
When in doubt, use ( .. ) brackets to ensure the expression is correct