In the following table of operator precedence,
the
operators are divided into 16 categories.
The #1 category has the highest precedence; category #2 (Unary operators) takes second precedence, and so on to the Comma operator, which has lowest precedence.
The operators within each category have equal precedence.
All of the operators in this table can be overloaded except the following:
. C++ direct component selector
.* C++ dereference
:: C++ scope access/resolution
?: Conditional
The #1 category has the highest precedence; category #2 (Unary operators) takes second precedence, and so on to the Comma operator, which has lowest precedence.
The operators within each category have equal precedence.
| Category | Operator | What
it is (or does) | Association |
| 1. Highest | () | Function call | L-R |
| [] | Array subscript | L-R | |
| -> | C++ indirect component selector | L-R | |
| :: | C++ scope access/resolution | L-R | |
| . | C++ direct component selector | L-R | |
| 2. Unary | ! | Logical negation (NOT) | R-L |
| ~ | Bitwise (1’s) complement | R-L | |
| + | Unary plus | R-L | |
| - | Unary minus | R-L | |
| ++ | Preincrement or postincrement | R-L | |
| -- | Predecrement or postdecrement | R-L | |
| & | Address | R-L | |
| * | Indirection | R-L | |
| sizeof | (returns size of operand, in bytes) | R-L | |
| new | (dynamically allocates C++ storage) | R-L | |
| delete | (dynamically deallocates C++ storage) | R-L | |
| 3. Multiplicative | * | Multiply | L-R |
| / | Divide | L-R | |
| % | Remainder (moduls) | L-R | |
| 4. Member access | .* | C++ dereference | L-R |
| ->* | C++ dereference | L-R | |
| 5. Additive | + | Binary plus | L-R |
| - | Binary minus | L-R | |
| 6. Shift | << | Shift left | L-R |
| >> | Shift right | L-R | |
| 7. Relational | < | Less than | L-R |
| <= | Less than or equal to | L-R | |
| > | Greater than | L-R | |
| >= | Greater than or equal to | L-R | |
| 8. Equality | == | Equal to | L-R |
| != | Not equal to | L-R | |
| 9. | & | Bitwise AND | L-R |
| 10. | ^ | Bitwise XOR | L-R |
| 11. | | | Bitwise OR | L-R |
| 12. | && | Logical AND | L-R |
| 13. | || | Logical OR | L-R |
| 14. Conditional | ?: | (a ? x : y
means "if a then x, else y") | R-L |
| 15. Assignment | = | Simple assignment | R-L |
| *= | Assign product | R-L | |
| /= | Assign quotient | R-L | |
| %= | Assign reminder (modulus) | R-L | |
| += | Assign sum | R-L | |
| -= | Assign difference | R-L | |
| &= | Assign bitwise AND | R-L | |
| ^= | Assign bitwise XOR | R-L | |
| |= | Assign bitwise OR | R-L | |
| <<= | Assign left shift | R-L | |
| >>= | Assign right shift | R-L | |
| 16. Comma | , | Evaluate | L-R |
All of the operators in this table can be overloaded except the following:
. C++ direct component selector
.* C++ dereference
:: C++ scope access/resolution
?: Conditional