December 2002
Beginner to intermediate
576 pages
14h 6m
English
The tables in this appendix summarize the precedence rules for operations in C++.
Table C-1. Standard C++ precedence rules
Precedence | Operators | ||||
|---|---|---|---|---|---|
1 | ( ) | [ ] | -> | . | |
:: | ::* | ->* | .* | ||
2 | ! | ~ | ++ | -- | (type) |
- (unary) | * (dereference) | ||||
& (address of) | sizeof | ||||
3 | * (multiply) | / | % | ||
4 | + | - | |||
5 | << | >> | |||
6 | < | <= | > | >= | |
7 | == | != | |||
8 | & (bitwise AND) | ||||
9 | ^ | ||||
10 | | | ||||
11 | && | ||||
12 | || | ||||
13 | ?: | ||||
14 | = | += | -= | etc. | |
15 | , |
Table C-2. Practical operator precedence rules
Precedence | Operator | ||
|---|---|---|---|
1 | * (multiply) | / | % |
2 | + | - |
Put parentheses around everything else.
Read now
Unlock full access