A.1. Operator Precedence

Operators are shown in decreasing order of precedence from top to bottom (Fig. A.1).

Fig. A.1. Operator precedence and associativity chart.
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 postfix increment

unary postfix decrement

runtime type information

runtime type-checked cast

compile-time type-checked cast

cast for nonstandard conversions

cast away const-ness
left to right
++

--

+



!

~

sizeof

&

*

new

new[]

delete

delete[]
unary prefix increment

unary prefix decrement

unary plus

unary minus

unary logical negation

unary bitwise complement

determine size in bytes

address

dereference

dynamic memory allocation

dynamic array allocation

dynamic memory deallocation

dynamic array deallocation
right to left
( type ) C-style unary cast 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 assignment
right to left
, comma left to right