operator precedence in cpp

Operator Precedence in C++

  1. Postfix operators: (), [], ., ->, ++, --

  2. Unary operators: +, -, !, ~, ++, --, *, &, sizeof, new, delete

  3. Multiplicative operators: *, /, %

  4. Additive operators: +, -

  5. Shift operators: <<, >>

  6. Relational operators: <, <=, >, >=

  7. Equality operators: ==, !=

  8. Bitwise AND operator: &

  9. Bitwise XOR operator: ^

  10. Bitwise OR operator: |

  11. Logical AND operator: &&

  12. Logical OR operator: ||

  13. Conditional operator: ? :

  14. Assignment operators: =, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=

  15. Comma operator: ,

These rules specify the order in which operators are evaluated when they appear together in an expression.