[C/C++] 关于C/C++操作符的结合律
Associativity Rules
The associativity rules of a language specify which operator is evaluated first when two operators with the same precedence are adjacent in an expression.
当一个表达式中有两个相同优先级的操作符相邻时,结合律规定了哪个操作符先进行操作。
[例]
x = 3 + 2 - 1;
因为这里的加(+)操作符和减(-)操作符优先级相同,而+、-的结合律都是从左向右的,所以先执行加法,后执行减法,所以x的结果为4。
[参考资料]
1. http://cs.smu.ca/~porter/csc/ref/cpp_operators.html