Table of Precedence and Associativity
The table below is arranged from highest to lowest precedence as you go from top to bottom. Operators between dashed lines have the same "precedence level", of which you will note that there are 18. Associativity information is given in the center column, in which LR=Left-to-Right associativity and RL=Right-to-Left associativity).
Operators Assoc Description
----------------------------------------------------------------------
(expression) parentheses used for grouping
:: RL (unary) global scope resolution operator
:: LR class scope resolution operator
----------------------------------------------------------------------
() LR parentheses used for a function call
() LR value construction, as in type(expression)
. LR member selection via struct or class object
-> LR member selection via pointer
[] LR array element access
const_cast LR specialized type cast
dynamic_cast LR specialized type cast
reinterpret_cast LR specialized type cast
static_cast LR specialized type cast
typeid LR type identification
++ -- LR postfix versions of increment/decrement
----------------------------------------------------------------------
All the operators in this section are unary (one argument) operators.
++ -- RL prefix versions of increment/decrement
+ - RL unary versions
! RL logical NOT
~ RL bitwise complement ("ones complement")
& RL address of
* RL dereference
new RL allocates memory to dynamic object
delete RL de-allocates memory allocated to dynamic object
new [] RL allocates memory to dynamic array
delete [] RL de-allocates memory allocated to dynamic array
sizeof RL for computing storage size of data
(type) RL cast (C-style type conversion)
----------------------------------------------------------------------
.* LR struct/union/object pointer (member dereference)
->* LR pointer to struct/union/object pointer
(indirect member dereference)
----------------------------------------------------------------------
* / % LR multiplication and division
----------------------------------------------------------------------
+ - LR addition and subtraction
----------------------------------------------------------------------
>> << LR input and output stream operators
----------------------------------------------------------------------
< <= > >= LR inequality relational
----------------------------------------------------------------------
== != LR equality relational
----------------------------------------------------------------------
& LR bitwise AND
----------------------------------------------------------------------
^ LR bitwise XOR
----------------------------------------------------------------------
| LR bitwise OR
----------------------------------------------------------------------
&& LR logical AND
----------------------------------------------------------------------
|| LR logical OR
----------------------------------------------------------------------
?: RL conditional
----------------------------------------------------------------------
= RL assignment
*= RL multiplication and assignment
/= RL division and assignment
%= RL modulus (remainder) and assignment
+= RL addition and assignment
-= RL subtraction and assignment
----------------------------------------------------------------------
throw LR throw exception
----------------------------------------------------------------------
, LR the operator, not the separator
(combines two expressions into one)
----------------------------------------------------------------------
No comments:
Post a Comment