A Operator Precedence and Associativity

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

You can't read the all page of ebook, please click here login for view all page.
Reset