the following may help determine wheter an object is a lvalue or rvalue: if the object obtained from an expression has a name, then it must be lvalue; otherwise it is rvalue. this means all temporary objects must be rvalues. example:
++a; // the result is 'a ', which has a name -- 'a ', so it is lvalue. a++; // the result is a temporary object -- rvalue. a+5; // again, a temporary object -- rvalue. a=3; // the result is 'a ', which has a name, lvalue.
An lvalue is an expression denoting a nonconstant object.
-TCPL
a++ denoting a constant temporary object which equal to a before ++.
++a denoting a nonconstant object which is a after ++. |
a++ ++a 左值 右值
最新推荐文章于 2021-02-03 11:54:00 发布