Appendix C. Operator Precedence Rules
The tables in this appendix summarize the precedence rules for operations in C++.
Standard Rules
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 | , | Â | Â | Â | Â |
Practical Subset of the Operator Precedence Rules
Table C-2. Practical operator precedence rules
Precedence | Operator | Â | Â |
---|---|---|---|
1 | * (multiply) | / | % |
2 | + | - | Â |
Put parentheses around everything else.
Get Practical C++ Programming, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.