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 ...
Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.