C++ 运算符优先级和关联性
C++ 语言包括所有 C 运算符并添加多个新的运算符。 运算符指定对一个或多个操作数执行的计算。
运算符优先级别指定包含多个运算符的表达式中的运算顺序。 运算符关联性指定,在包含多个具有相同优先级别的运算符的表达式中,操作数与其左侧还是右侧的操作数组合。 下表显示 C++ 运算符的优先级别和关联性(从最高优先级别到最低优先级别)。 优先级别编号相同的运算符具有等同的优先级别,除非由括号显式施加另一种关系。
C++ 运算符的优先级别和关联性
运算符说明 |
---|
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 |