现在的位置: 首页 > 综合 > 正文

a++ ++a 左值 右值

2019年01月02日 ⁄ 综合 ⁄ 共 706字 ⁄ 字号 评论关闭
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   ++.

抱歉!评论已关闭.