...

Monday 29 December 2014

Operator Precedence and Associativity

Note: Operators are shown in decreasing order of precedence from top to bottom in the table.

Operator Type Associativity
: : binary scope resolution left to right
: : unary scope resolution left to right
( ) parentheses left to right
[ ] array subscript left to right
. member selection via object left to right
-> member selection via pointer left to right
+ + unary postfix increment left to right
- - unary postfix decrement left to right
typeid runtime type information left to right
dynamic_cast <type> runtime type-checked cast left to right
static_cast <type> compile-time type-checked cast left to right
reinterpret_cast <type> cast for nonstandard conversions left to right
const_cast <type> cast away const-ness left to right
+ + unary prefix increment right to left
- - unary prefix decrement right to left
+ unary plus right to left
- unary minus right to left
! unary logical negation right to left
~ unary bitwise complement right to left
sizeof determine size in bytes right to left
& address right to left
* dereference right to left
new dynamic memory allocation right to left
new[ ] dynamic array allocation right to left
delete dynamic memory deallocation right to left
delete[ ] dynamic array deallocation right to left
( type ) C-style unary cast right to left
.* pointer to member via object left to right
->* pointer to member via pointer left to right
* multiplication left to right
/ division left to right
% modulus left to right
+ addition left to right
- subtraction left to right
<< bitwise left shift left to right
>> bitwise right shift left to right
< relational less than left to right
<= relational less than or equal to left to right
> relational greater than left to right
>= relational greater than or equal to left to right
= = relational is equal to left to right
!= 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 right to left
+= addition assignment right to left
- = subtraction assignment right to left
* = multiplication assignment right to left
/= division assignment right to left
%= modulus assignment right to left
&= bitwise AND assignment right to left
^= bitwise exclusive OR assignment right to left
|= bitwise inclusive OR assignment right to left
<<= bitwise left-shift assignment right to left
>>= bitwise right-shift assignment right to left
, comma left to right

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Favorites More

 
Design by MA Technologies | Bloggerized by Computer Science Prevails