Operator Precedence Chart


Operators are shown in decreasing order of precedence from top to bottom.

Operator

Type

Associativity

::

::

binary scope resolution

unary scope resolution

left to right

()
[]
.

->

++

--

typeid

dynamic_cast<  type  >

static_cast<  type  >

reinterpret_cast<  type  >

const_cast<  type  >

parentheses
array subscript
member selection via object

member selection via pointer

unary postincrement

unary postdecrement

run-time type information

run-time type-checked cast

compile-time type-checked cast

cast for non-standard conversions

cast away const-ness

left to right

++
--
+
-
!
~
(
type )

sizeof

&

*

new

new[]

delete

delete[]

unary preincrement
unary predecrement
unary plus
unary minus
unary logical negation
unary bitwise complement
C-style unary cast

determine size in bytes

address

dereference

dynamic memory allocation

dynamic array allocation

dynamic memory deallocation

dynamic array deallocation

right to left

.*

->*

pointer to member via object

pointer to member via pointer

left to right

*
/
%

multiplication
division
modulus

left to right

+
-

addition
subtraction

left to right

<<
>>

bitwise left shift
bitwise right shift

left to right

<
<=
>
>=

relational less than
relational less than or equal to
relational greater than
relational greater than or equal to

left to right

==
!=

relational is equal to
relational is not equal to

left to right

&

bitwise AND

left to right

^

bitwise exclusive OR

left to right

|

bitwise inclusive OR

left to right

&&

logical AND

left to right

||

logical OR

left to right

?:

ternary conditional

right to left

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

assignment
addition assignment
subtraction assignment
multiplication assignment
division assignment
modulus assignment
bitwise AND assignment
bitwise exclusive OR assignment
bitwise inclusive OR assignment
bitwise left shift assignment
bitwise right shift with sign

right to left

,

comma

left to right