What are Boolean Literals in C++?

Boolean literals are literals that have either the meaning true or false. There are only two Boolean literals in C++: true and false. These literals are of type bool. You can use them as −


using namespace std;

int main() {
   bool my_bool = true;
   if(my_bool) {
      cout << "My bool is true!" << endl;
   return 0;


This will give the output −

My bool is true!