|
|
|||
![]() |
Department of Engineering |
| University of Cambridge > Engineering Department > computing help |
The lines of the table are in order of precedence, so `a * b + 6' is interpreted as `(a * b) + 6'. When in doubt put brackets in!
The Associativity column shows how the operators group. E.g. `' groups left to right, meaning that is equivalent to rather than . Both are pretty useless expressions.
| Associativity | Operator |
|---|---|
| left to right | () [], ->, . |
| right to left | ! (negation), ~ (bit-not) |
++, --, - (unary) , * (unary), & (unary), sizeof |
|
| right to left | cast (type) |
| left to right | *, /, % (modulus) |
| left to right | - + |
| left to right | <<, >> |
| left to right | <, <=, >, >= |
| left to right | ==, != |
| left to right | & (bit-and), | (bit-or) |
| left to right | ^ (bit-xor) |
| left to right | && (logical and) |
| left to right | || (logical or) |
| right to left | ?: |
| right to left | =, +=, -=, /=, %=, >>=, &= |
| left to right | , |