"

Appendix B: C++ Operators, Precedence, and Associativity Rules

Hussam Ghunaim, Ph.D.

C++ has many operators, precedence, and associativity rules. Below is a short list. (source: C++ built-in operators, precedence, and associativity | Microsoft Learn)

Operator Description Operator Alternative
Group 1 precedence, no associativity
Scope resolution ::
Group 2 precedence, left to right associativity
Function call ()
Postfix increment ++
Postfix decrement --
Static type conversion static_cast
Group 3 precedence, right to left associativity
Size of object or type sizeof
Prefix increment ++
Prefix decrement --
Logical not ! not
Unary negation -
Unary plus +
Address-of &
Indirection *
Group 5 precedence, left to right associativity
Multiplication *
Division /
Modulus %
Group 6 precedence, left to right associativity
Addition +
Subtraction -
Group 8 precedence, left to right associativity
Less than <
Greater than >
Less than or equal to <=
Greater than or equal to >=
Group 9 precedence, left to right associativity
Equality ==
Inequality != not_eq
Group 13 precedence, left to right associativity
Logical AND && and
Group 14 precedence, left to right associativity
Logical OR || or
Group 15 precedence, right to left associativity
Conditional ? :
Assignment =
Multiplication assignment *=
Division assignment /=
Modulus assignment %=
Addition assignment +=
Subtraction assignment -=
Group 16 precedence, left to right associativity
Comma ,

 

License

Icon for the Creative Commons Attribution 4.0 International License

Introduction to C++ ( Volume I ) Copyright © 2025 by Hussam Ghunaim, Ph.D. is licensed under a Creative Commons Attribution 4.0 International License, except where otherwise noted.