在 C 中,圆括号用于进行更多操作,例如函数调用和类型转换。
然而它们也被用来组合许多子表达式来改变 运算符的顺序评估。
我的疑问是:当用作分组运算符时,它们是否被视为运算符?
很多人说是,很多人说不是...
最佳答案
6.5 表达式章节 (N1570) 第 3 段
The grouping of operators and operands is indicated by the syntax. 85)
有以下注释:
85) The syntax specifies the precedence of operators in the evaluation of an expression, which is the same as the order of the major subclauses of this subclause, highest precedence first. Thus, for example, the expressions allowed as the operands of the binary + operator (6.5.6) are those expressions defined in 6.5.1 through 6.5.6. The exceptions are cast expressions (6.5.4) as operands of unary operators (6.5.3), and an operand contained between any of the following pairs of operators: grouping parentheses () (6.5.1), subscripting brackets [] (6.5.2.1), function-call parentheses () (6.5.2.2), and the conditional operator ?: (6.5.15).
所以 C 标准似乎将它们视为运算符。
关于c - 用于分组的圆括号是否被视为运算符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24238686/