C++ Operators, Precedence and Associativity
The C++ language includes all C operators and adds several new operators. Operators specify an evaluation to be performed on one or more operands.
Operator precedence specifies the order of operations in expressions that contain more than one operator. Operator associativity specifies whether, in an expression that contains multiple operators with the same precedence, an operand is grouped with the one on its left or the one on its right. The following table shows the precedence and associativity of C++ operators (from highest to lowest precedence). Operators with the same precedence number have equal precedence unless another relationship is explicitly forced by parentheses.
C++ Operator Precedence and Associativity
Operator Description |
---|
Group 1 precedence, no associativity |
Group 2 precedence, left to right associativity |
Group 3 precedence, right to left associativity |
Group 4 precedence, left to right associativity |
Group 5 precedence, left to right associativity |
Group 6 precedence, left to right associativity |
Group 7 precedence, left to right associativity |
Group 8 precedence, left to right associativity |
Group 9 precedence, left to right associativity |
Group 10 precedence left to right associativity |
Group 11 precedence, left to right associativity |
Group 12 precedence, left to right associativity |
Group 13 precedence, left to right associativity |
Group 14 precedence, left to right associativity |
Group 15 precedence, right to left associativity |
Group 16 precedence, right to left associativity |
Group 17 precedence, right to left associativity |
Group 18 precedence, left to right associativity |