Appendix C. 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. The lower an operator’s rank in Table C.1, the higher its precedence.

Table C.1. The Precedence of Operators

Rank

Name

Operator

1

Scope resolution

::

2

Member selection, subscripting, function calls, postfix increment and decrement

. ->

  

()

  

++ --

3

Sizeof, prefix increment and decrement, complement, and, not, unary minus and plus, ...

Get Sams Teach Yourself C++ in One Hour a Day, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.