0

Look at the following code:

int a = 1;
(++a)++;

If I write this code in C souce file, and use gcc to compile it, the result is that:

Increment operator needs lvalue

But if i write this code in c++ source file, use g++ compiler to compile it, there is no error. . According to 《C++ primer 5e》, prefix increment operator returns a lvalue.

So, ++a is a lvalue, why (++a)++ is wrong?

skypjack
  • 47,379
  • 17
  • 84
  • 173
linyuwang
  • 301
  • 3
  • 10

0 Answers0