C and C++ Operators

Operators Description Associativity
:: Scope resolution N/A
++ --

()
[]
.
->

Postfix increment and decrement

Function call
Array subscript
Element selection by reference
Element selection by pointer

left-to-right
++ --

+ -
! ~
(type)
*
&
sizeof
new delete

Prefix increment and decrement

Unary plus and minus
Logical NOT and bitwise zero's complement
Type cast
Dereference
Reference (address-of)
Size of
Dynamic memory (de)allocation

right-to-left
.* ->* Pointer to member left-to-right
* / % Multiplication, division, and modulus (remainder)
+ - Addition and subtraction
<< >> Bitwise left shift and right shift
< <=

> >=

Relational “less than” and “less than or equal to”

Relational “greater than” and “greater than or equal to”

== != Relational “equal to” and “not equal to”
& Bitwise AND
^ Bitwise XOR (exclusive or)
| Bitwise OR (inclusive or)
&& Logical AND
|| Logical OR
c?t:f Ternary conditional right-to-left
=

+= -=
*= /= %=
<<= >>=
&= ^= |=

Direct assignment

Assignment by sum and difference
Assignment by product, dividend, and remainder
Assignment by bitwise shift
Assignment by bitwise AND, XOR, and OR

, Comma left-to-right