Output boolean variable as boolean literal or number : bool « Data Types « C++ Tutorial






#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char** argv)
{
  bool myBool = true;

  cout << "This is the default: " << myBool << endl;
  cout << "This should be true: " << boolalpha << myBool << endl;
  cout << "This should be 1: " << noboolalpha << myBool << endl;

}








2.6.bool
2.6.1.bool values
2.6.2.A bool value can control the if statement
2.6.3.Outcome of a relational operator is a true/false value
2.6.4.Variable size of bool
2.6.5.The || Operator
2.6.6.The !(Exclamation mark) Operator
2.6.7.The && Operator (amplifier)
2.6.8.Output boolean variable as boolean literal or number
2.6.9.Use bool value to control a while loop
2.6.10.Logical operators.