Appendix B. Operator Precedence

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

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. Table B.1 lists the C++ operators by precedence.

Table B.1. Operator Precedence
Rank Name Operator
1 Scope resolution ::
2 Member selection, subscripting, function calls, postfix increment and decrement . ->

()

++ --
3 Prefix increment and decrement, complement, and, not, unary minus and plus, address of and dereference, new, new[], delete, delete[], casting, size of, sizeof() ++ --

^ !

- +

& *

()
4 Member selection for pointer .* ->*
5 Multiply, divide, modulo * / %
6 Add, subtract + -
7 Shift << >>
8 Inequality relational < <= > >=
9 Equality, inequality == !=
10 Bitwise and &
11 Bitwise exclusive or ^
12 Bitwise or |
13 Logical and &&
14 Logical or ||
15 Conditional ?:
16 Assignment operators = *= /= %=

+= -= <<= >>=

&= |= ^=
17 Throw operator throw
18 Comma ,

..................Content has been hidden....................

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