Sail E0 Webinar
Question

Which of the two operators ++ and - work for the bool datatype in C++?


Options:
A .  None
B .  ++
C .  -
D .  Both
Answer: Option B

Due to 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’s not possible to predict the result of — given knowledge only of the truth value of x, as 

it could result in false.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers