C++ 中的赋值运算符返回右值还是左值?如果它是左值,两个参数中的哪一个会在这里递增?
(a = b)++
最佳答案
它返回一个左值。根据 § 5.17:
The assignment operator (=) and the compound assignment operators all group right-to-left. All require a modifiable lvalue as their left operand and return an lvalue referring to the left operand.
如果那些对象有一个用户定义的赋值运算符,那么它取决于operator=
的实现和声明(返回类型)。
通常情况下,之后
(a = b)++
对象 a
将递增。
关于c++ - C++ 中的赋值运算符返回右值还是左值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19244627/