bool literal

From cppreference.com
< cpp‎ | language

[edit] Syntax

true (1)
false (2)

[edit] Explanation

  1. boolean true (a prvalue of type bool, implicitly convertible to the value 1 of type int.)
  2. boolean false (a prvalue of type bool, implicitly convertible to the value 0 of type int.)

[edit] Example

#include <iostream>
 
int main()
{
  std::cout << std::boolalpha
            << true << '\n'
            << false << '\n'
            << std::noboolalpha
            << true << '\n'
            << false << '\n';
}

Output:

true
false
1
0