Monday, 14 October 2013

Operator Precedence In C++

Appendix A

Operator Precedence


It is important to understand that operators have a precedence, but it is not essential to memorize the precedence.

New Term: Precedence is the order in which a program performs the operations in a formula. If one operator has precedence over another operator, it is evaluated first.

Higher precedence operators "bind tighter" than lower precedence operators; thus, higher precedence operators are evaluated first. The lower the rank in the following chart, the higher the precedence.

Table A.1. Operator Precedence.
RankNameOperator
1scope resolution::
2member selection, subscripting,. ->
function calls, postfix increment()
and decrement++ --
3sizeof, prefix increment and decrement,++ --
complement, and, not, unary minus and plus,^ !
address of and dereference, new, new[], delete,- +
delete[], casting, sizeof(),& *
()
4member selection for pointer.* ->*
5multiply, divide, modulo* / %
6add, subtract+ -
7shift<< >>
8inequality relational< <= > >=
9equality, inequality== !=
10bitwise AND&
11bitwise exclusive OR^
12bitwise OR|
13logical AND&&
14logical OR||
15conditional?:
16assignment operators= *= /= %=
+= -= <<= >>=
&= |= ^=
17throw operatorthrow
18comma,

No comments:

Post a Comment