This project has moved and is read-only. For the latest updates, please go here.

Operator precedence

The following is a table that lists the precedence and associativity of all the operators in the C and C++ languages. Operators are listed top to bottom, in descending precedence. Descending precedence refers to the priority of evaluation. Operators that are in the same cell (there may be several rows of operators listed in a cell) are evaluated with the same precedence. An operator's precedence is unaffected by overloading.

Precedence Operator Description Associativity


:: Scope resolution (C++ only)                                               None
2 ++ Suffix increment Left-to-right
-- Suffix decrement
() Function call
[] Array subscripting
. Element selection by reference
-> Element selection through pointer
typeid() Run-time type information (C++ only) 
const_cast Type cast (C++ only) 
dynamic_cast Type cast (C++ only) 
reinterpret_cast Type cast (C++ only)
static_cast Type cast (C++ only) 
3 ++ Prefix increment Right-to-left
-- Prefix decrement
+ Unary plus
- Unary minus
! Logical NOT
~ Bitwise NOT (One's Complement)
(type) Type cast
* Indirection (dereference)
& Address-of
sizeof Size-of
newnew[] Dynamic memory allocation (C++ only)
deletedelete[] Dynamic memory deallocation (C++ only)
4 .* Pointer to member (C++ only) Left-to-right
->* Pointer to member (C++ only)
5 * Multiplication Left-to-right
/ Division
% Modulo (remainder)
6 + Addition Left-to-right
- Subtraction
7 << Bitwise left shift Left-to-right
>> Bitwise right shift
8 < Less than Left-to-right
<= Less than or equal to
> Greater than
>= Greater than or equal to
9 == Equal to Left-to-right
!= Not equal to
10 & Bitwise AND Left-to-right
11 ^ Bitwise XOR (exclusive or) Left-to-right
12 | Bitwise OR (inclusive or) Left-to-right
13 && Logical AND Left-to-right
14 || Logical OR Left-to-right
15 ?: Ternary conditional  Right-to-left
16 = Direct assignment Right-to-left
+= Assignment by sum
-= Assignment by difference
*= Assignment by product
/= Assignment by quotient
%= Assignment by remainder
<<= Assignment by bitwise left shift
>>= Assignment by bitwise right shift
&= Assignment by bitwise AND
^= Assignment by bitwise XOR
|= Assignment by bitwise OR
17 throw Throw operator (exceptions throwing, C++ only) Right-to-left


, Comma Left-to-right

Last edited Dec 22, 2015 at 7:59 AM by vineetchoudhary, version 1