   strange but it works
  i++++; fails and I understand why but ++++i; works, shouldn't it fail alsoWe are still trying to increment non-lvalue....what say?   
  The return value of i++ is an rvalue, but the return value of ++i is an lvalue.   ;Quote:Original post by Japanesei++++; fails and I understand why but ++++i; works, shouldn't it fail alsoWe are still trying to increment non-lvalue....what say?Fomr the Holy One, section 5.3.2 (Increment and decrement), §1:Quote:The operand of prefix ++ is modified by adding 1 <...>. The operand shall be a modifiable lvalue. <...> The value is the new value of the operand; it is a lvalue. <...>Emphasis is mine.HTH,   ;  Plz see thishttp://groups.google.com/group/comp.lang.c/browse_thread/thread/8a430046f8ba405c/8672a98fab1e946b?lnk=st&q=why+i%2B%2B%2B%2B+is+invalid&rnum=2&hl=en#8672a98fab1e946b   ;  Ok, I see a non-hyperlinked URL with no indication why you would post it, or for that matter why I would bother visiting it. Do you have some problem following the discussion in that thread? Do you believe that what that thread said is in contradiction with what was said in this thread? Or do you just like posting links to random URLs?   ;  No. It's not a random link. If you read the post of the last person in that link it contradicts what you say.Here it isQuote:No, it isn't. This will not even compile. (Well, technically,theoretically, it might. As long as the error is diagnosed, thecompiler can do whatever it likes with this broken code. But in thereal world, compilers will cease compilation.) The expression ++++iparses as ++(++i), which, of course, is nonsensical. You cannotincrement a non-lvalue. (An lvalue is an object. i is an object, andtherefore an lvalue. But ++i is not an object, and therefore not anlvalue. Thus it cannot be applied to the ++ operator again.)Similarly, i++++ is an error.;  His basic argument is ok, but the definition of lvalue is messed up. '++i' increments i and yields the *new* value, by reference; thus it refers again to i, which is still a new value. '++i' increments i, yielding the *old* value; since 'i' is changed, this old value must necessarily be yielded by a temporary, and temporaries aren't lvalues.   ;Quote:Original post by JapaneseNo. It's not a random link. If you read the post of the last person in that link it contradicts what you say.Let's see here: all the compilers I know accept ++++i and the C++ Standard says that ++i is an lvalue. I'm going to go out on a limb and say that the guy you quoted is wrong.Quote:Original post by Zahlman... and temporaries aren't lvalues.Some temporaries can be lvalues. Ex: the return value of a function that returns a non-const class type by value is both an lvalue and a temporary. For this reason i++++ can be a valid expression if i is of a class type.   ;  Note that while ++++i; is syntactically valid it is only semantically valid if i is an instance of a user-defined type with an operator++(), due to sequence points, as discussed briefly in GotW #78.Σnigma   ;Quote:Original post by SiCraneFor this reason i++++ can be a valid expression if i is of a class type.that depends on how the operator is overloaded in the class.