Operator Precedence in C++

The table below defines operator precedence (and associativity) in C++. Hover on any of the operators in the precedence table for further information.

A bullet () represents the operand in unary versions of some operators, for disambiguation.

P.
Arithmetic
,
Bitwise
,
Logical
,
Relational
,
Pointer/Member
and
Other

Operators
As.
1
::
::
LTR
2
++
--
.
->
[]
(args)
typeid
3
++
--
+
-
!
~
*
&
(type)
sizeof
new
delete
new[]
delete[]
RTL
4
.*
->*
LTR
5
*
/
%
Arithmetic
6
+
-
7
<<
>>
Bitwise shift
8
<
<=
>
>=
Relational
9
==
!=
10
&
Bitwise
11
^
12
|
13
&&
Logical
14
||
15
? :
=
*=
/=
%=
+=
-=
<<=
>>=
&=
^=
|=
Conditional and Assignment RTL
16
throw
N/A
17
,
LTR

Note 1: The following operators were omitted for brevity. They belong to precedence level 2.

dynamic_cast
static_cast
const_cast
reinterpret_cast

Note 2: Contrary to many sources, this is indeed the correct precedence and associativity for the ternary operator. See this.

C++ not your language? Select a different programming language.

Questions, comments ==> info (at) (this domain)

Other quick-reference sites:   db9-pinout.com | resistor-color-codes.com | hex-codes.com

Cheap NFL Jerseys Cheap NFL Jerseys goedkope air max online Basket Air Jordan 11 Christian Louboutin Outlet Cheap Jerseys Wholesale Jerseys Michael Kors Outlet Online Ray Ban Sunglasses Jerseys Wholesale Coach Outlet Store michael jordan air jordan 11 Coach Outlet Cheap NFL Jerseys Kate Spade Outlet Sale air max 90 pas cher junior Wholesale Jerseys Jerseys Cheap nba jerseys vegas Jerseys Wholesale China