bool operator ++ and --

后端 未结 4 711
遥遥无期
遥遥无期 2020-11-29 01:03

Today while writing some Visual C++ code I have come across something which has surprised me. It seems C++ supports ++ (increment) for bool, but not -- (decrement). It this

4条回答
  •  野性不改
    2020-11-29 01:45

    • With the old standards (C++98) it is not an error.
    • With the new standards incrementing a boolean is deprecated. (C++11)
    • You can use incrementation on a boolean until C++17.

提交回复
热议问题