Why are multiple increments/decrements valid in C++ but not in C?

前端 未结 4 1515
太阳男子
太阳男子 2021-01-18 05:09

test.(c/cpp)

#include 

int main(int argc, char** argv)
{
  int a = 0, b = 0;
  printf(\"a = %d, b = %d\\n\", a, b);
  b = (+         


        
4条回答
  •  伪装坚强ぢ
    2021-01-18 05:36

    §5.2.7 Increment and decrement:

    The value of a postfix ++ expression is the value of its operand. [ ... ]  The operand shall be a modifiable lvalue.

    The error you get in your C compilation helps to suggest that this is only a feature present in C++.

提交回复
热议问题