C++ Operators

When looking at the precedence level column, remember level 1 is the highest precedence and each level thereafter has less and less precedence.

Precedence Level Operators Order of Evaluation
1 ( ) . [ ] -> :: Left to Right
2 * & ! ~ ++ — + – sizeof new delete Right to Left
3 .* -> * Left to Right
4 * / % Left to Right
5 + – Left to Right
6 << >> Left to Right
7 < <= > >= Left to Right
8 == != Left to Right
9 & Left to Right
10 ^ Left to Right
11 | Left to Right
12 && Left to Right
13 || Left to Right
14 ?: Right to Left
15 = *= /= += -= %= <<= >>= &= ^= |= Right to Left
16 , Left to Right

NOTES:

  • Precedence Level 2 + and – are unary plus (+) and unary minus (-)
  • Precedence Level 2 & is the address-of operator whereas the & at Precedence Level 9 is the bitwise AND operator
  • Precedence Level 2 * is the pointer-dereference operator whereas the * at Precedence Level 4 is the multiplication operator

Add a Comment

Your email address will not be published. Required fields are marked *