C++ operator precedence table

The highest precedence operators appear first in the list. Operators in the same box each have equal precedence, and the order of application depends on the associativity labeled in the rightmost column.

Operator Type Associativity
::
::
binary scope resolution
unary scope resolution
left to right
()
[]
.
->
++

typeid
dynamic_cast<
type
>
static_cast
reinterpret_cast
const_cast
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
++

+

!
~
( 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
left to right
.*
->*
pointer to member via object
pointer to member via pointer
*
/
%
multiplication
division
modulus
+
addition
subtraction
<<
>>
bitwise left shift
bitwise right shift
<
<=
>
>=
relational less than
relational less than or equal to
relational
greater than
relational greater than or equal to
==
!=
relational is equal to
relational is not equal to
& bitwise AND
^ bitwise exclusive OR
| bitwise inclusive OR
&& logical AND
|| logical OR
?: 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 assignment
, comma left to right
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s