__shivam_kumar's blog

By __shivam_kumar, history, 5 years ago, In English

you cannot do nesting of post-increment operator whereas pre-increment nesting does not cause any problem

conclusion : never do post increment nesting

eg :

int a = 10;

 cout<<(++(++a))<<"\n";// valid in c++

 cout<<((a++)++); // in-valid in c++
Tags c++
  • Vote: I like it
  • -21
  • Vote: I do not like it

| Write comment?
»
5 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why is it so? What error can it cause?

  • »
    »
    5 years ago, hide # ^ |
    ← Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    It is not possible to post-increment an r-value.

    The value obtained by applying a postfix ++ is the value that the operand had before applying the operator. The operand shall be a modifiable lvalue. The result is an rvalue.