Operator | Description | Prec. | Assoc. | Arity | Overld | Example |
: : | Global scope resolution | 17 | Right | Unary | No | ::x |
: : | Class scope resolution | 17 | Left | Binary | No | X::x |
. | Direct member selection | 16 | Left | Binary | No | s.len |
-> | Indirect member selection | 16 | Left | Binary | Yes | p->len |
[] | Subscript | 16 | Left | Binary | Yes | a[i] |
() | Function call | 16 | Left | n/a | Yes | abs(n) |
() | Type construction | 16 | Left | n/a | Yes | int(ch) |
++ | Post-increment | 16 | Right | Unary | Yes | n++ |
-- | Post-decrement | 16 | Right | Unary | Yes | n-- |
sizeof | Size of object or type | 15 | Right | Unary | No | sizeof(a) |
++ | Pre-increment | 15 | Right | Unary | Yes | ++n |
-- | Pre-decrement | 15 | Right | Unary | Yes | --n |
~ | Bitwise NOT | 15 | Right | Unary | Yes | ~s |
! | Logical NOT | 15 | Right | Unary | Yes | !p |
+ | Positive | 15 | Right | Unary | Yes | +n |
- | Negative | 15 | Right | Unary | Yes | -n |
* | Dereference | 15 | Right | Unary | Yes | *p |
& | Address | 15 | Right | Unary | Yes | &x |
new | Allocation | 15 | Right | Unary | Yes | new p |
delete | Deallocation | 15 | Right | Unary | Yes | delete p |
() | Type conversion | 15 | Right | Binary | Yes | (int)ch |
.* | Direct member selection | 14 | Left | Binary | No | x.*q |
->* | Indirect member selection | 14 | Left | Binary | Yes | p->*q |
* | Multiplication | 13 | Left | Binary | Yes | m * n |
/ | Division | 13 | Left | Binary | Yes | m / n |
% | Remainder | 13 | Left | Binary | Yes | m % n |
+ | Addition | 12 | Left | Binary | Yes | m + n |
- | Subtraction | 12 | Left | Binary | Yes | m - n |
<< | Bit shift left | 11 | Left | Binary | Yes | cout << n |
>> | Bit shift right | 11 | Left | Binary | Yes | cin >> n |
< | Less than | 10 | Left | Binary | Yes | x < y |
<= | Less than or equal to | 10 | Left | Binary | Yes | x <= y |
> | Greater than | 10 | Left | Binary | Yes | x > y |
>= | Greater than or equal to | 10 | Left | Binary | Yes | x >= y |
== | Equal to | 9 | Left | Binary | Yes | x == y |
!= | Not equal to | 9 | Left | Binary | Yes | x != y |
& | Bitwise AND | 8 | Left | Binary | Yes | s & t |
^ | Bitwise XOR | 7 | Left | Binary | Yes | s ^ t |
| | Bitwise OR | 6 | Left | Binary | Yes | s | t |
&& | Logical AND | 5 | Left | Binary | Yes | u && v |
|| | Logical OR | 4 | Left | Binary | Yes | u || v |
? : | Conditional expression | 3 | Left | Ternary | No | u ? x : y |
= | Assignment | 2 | Right | Binary | Yes | n = 22 |
+= | Addition assignment | 2 | Right | Binary | Yes | n += 8 |
-= | Subtraction assignment | 2 | Right | Binary | Yes | n -= 4 |
*= | Multiplication assignment | 2 | Right | Binary | Yes | n *= -1 |
/= | Division assignment | 2 | Right | Binary | Yes | n /= 10 |
%= | Remainder assignment | 2 | Right | Binary | Yes | n %= 10 |
&= | Bitwise AND assignment | 2 | Right | Binary | Yes | s &= mask |
^= | Bitwise XOR assignment | 2 | Right | Binary | Yes | s ^= mask |
|= | Bitwise OR assignment | 2 | Right | Binary | Yes | s |= mask |
<<= | Bit shift left assignment | 2 | Right | Binary | Yes | s <<= 1 |
>>= | Bit shift right assignment | 2 | Right | Binary | Yes | s >>= 1 |
throw | Throw exception | 1 | Right | Unary | Yes | throw(22) |
, | Comma | 0 | Left | Binary | Yes | ++m, --n |