0
int val = -10;
cout << ++(-val) << endl;

Output should be 11. But it gives me an error.

M. Blue
  • 11

1 Answers1

0

The error is "lvalue required as increment operand". This means that it's just a value; it does not represent a particular object like "val" anymore so trying to change it makes no sense to the compiler.

fatihk
  • 7,789
  • 1
  • 26
  • 48