19.2 TYPE Bool
A new data type bool is added to C++ recently. The term “bool” is a short form of Boolean. We have worked with if statement earlier. We test for a condition to be true or false before taking decision. Condition basically stands for a quantity having value true or false. Conditional expressions were returning value of type int. If the value is zero result is treated as false. For non-zero value, result is treated as true. This is only an arrangement. This arrangement continues even today.
Now C++ language supports keywords true and false.
The relationship between true and false can be expressed as:
! false == true and
! true == false
We can declare a variable as follows:
bool var1 ;
We can assign value true or false to this variable ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access