Home » C++ Programming » Data Types » Question
  1. Which of the two operators ++ and -- work for the bool data type in C++?
    1. --
    2. ++ & --
    3. ++
    4. All of above
    5. None of these
Correct Option: C

Due to the history of using integer values as booleans, if an integer is used as a boolean, then incrementing will mean that whatever its truth value before the operation, it will have a truth-value of true after it. However, it is not possible to predict the result of — given knowledge only of the truth value of x, as it could result in false.



Your comments will be displayed only after manual approval.