Error : Operand for operator “++” must be an lvalue

前端 未结 2 466
时光取名叫无心
时光取名叫无心 2021-01-27 11:56

In C++,

i = ++++j;

works fine in the code but when I use,

i = j++++;

I receive the following error:



        
2条回答
  •  终归单人心
    2021-01-27 11:59

    you are getting this error because the postfix operator returns a value and not a reference. But for clarity you should probably not do i=j++++; it might be more clear to say i = j += 2; or separate the lines into i = j+2; j+=2; or j+=2; i = j;.

提交回复
热议问题