What is the order of precedence for C++ operators?
The priority order of C++ operators is as follows:
- Unary operators (such as increment, decrement, negation, etc.)
- Multiplication, division, and modulus operators.
- Addition and subtraction operators.
- Bitwise operators, such as bit left shift and bit right shift.
- Relational operators (such as greater than, less than, equal to, etc.)
- Bitwise operators such as bitwise AND, bitwise OR.
- Logical operators (such as logical AND, logical OR)
- Ternary operator (Conditional operator)
- Assignment operator
- comma operator
It is important to note that parentheses can be used in an expression to change the order of operations. The expression within the parentheses will be calculated first.