C++ bool Keyword
Example
A boolean data type with true or false values:
bool isCodingFun = true;
bool isFishTasty = false;
cout << isCodingFun; // Outputs 1 (true)
cout << isFishTasty; // Outputs 0 (false)
Definition and Usage
The bool
keyword is a data type that can only take the values true
or false
.
Boolean values are mostly used for conditional testing (read the C++ Booleans Tutorial for more information).
Related Pages
Read more about data types in our C++ Data Types Tutorial.
Read more about booleans in our C++ Booleans Tutorial.