Appendix A: | Operator Precedence |
The following table lists C++'s precedence and associativity characteristics. Each box contains operators with equal precedence. The top box contains the highest-precedence operators.
Operator level | Associativity | |||
:: | left to right | |||
( ) [ ] -> . | left to right | |||
sizeof(data type) | ||||
! ++ -- | right to left | |||
+ (unary) - (unary) | ||||
* (dereference) & (address of) | ||||
new delete | ||||
(data type) | ||||
* / % | 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 | |||
Note that each data type, surrounded by parentheses, is considered an operator, namely a casting operator. Also, the parentheses following a function name are considered to be the function-call operator.
Three of the operators in the table are not described in the
body of this text: &
, |
, and {}
are the
bitwise and,
bitwise or,
and bitwise exclusive or operators.