![[Dept of Engineering]](http://www.eng.cam.ac.uk/images/house_style/engban-s.gif)
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 a<b<c is equivalent to (a < b) < c rather than a < (b < c). Both are pretty useless expressions - (a < b) evaluates to 1 or 0 depending on whether it's true or not.
| Associativity | Operator |
|---|---|
| left to right | :: |
| left to right | () [], ->, ., typeid, casts, |
| right to left | ! (negation), ~ (bit-not) |
new, delete
++, --, - (unary) , * (unary), & (unary), sizeof |
|
| right to left | (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 | throw |
| left to right | , |