Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Appendix A. Operator Precedence and Associativity

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.
OperatorTypeAssociativity
::binary scope resolutionleft to right
::unary scope resolution 
()grouping parentheses [See caution in Fig. 2.10] 
()function callleft to right
[]array subscript 
.member selection via object 
->member selection via pointer 
++unary postfix increment 
--unary postfix decrement 
typeidruntime 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 incrementright to left
--unary prefix decrement 
+unary plus 
-unary minus 
!unary logical negation 
~unary bitwise complement 
sizeofdetermine size in bytes 
&address 
*dereference 
newdynamic memory allocation 
new[]dynamic array allocation 
deletedynamic memory deallocation 
delete[]dynamic array deallocation 
( type )C-style unary castright to left
.*pointer to member via objectleft to right
->*pointer to member via pointer 
*multiplicationleft to right
/division 
%modulus 
+additionleft to right
subtraction 
<<bitwise left shiftleft to right
>>bitwise right shift 
>relational less thanleft to right
<=relational less than or equal to 
>relational greater than 
>=relational greater than or equal to 
==relational is equal toleft to right
!=relational is not equal to 
&bitwise ANDleft to right
^bitwise exclusive ORleft to right
|bitwise inclusive ORleft to right
&&logical ANDleft to right
||logical ORleft to right
?:ternary conditionalright to left
=assignmentright to left
+=addition assignment 
-=subtraction assignment 
*=multiplication assignment 
/=division assignment 
%=modulus assignment 
&=bitwise AND assignment 
^=bitwise exclusive OR assignment 
|=bitwise inclusive OR assignment 
<<=bitwise left-shift assignment 
>>=bitwise right-shift assignment 
,commaleft to right



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial