Namespaces
Variants
Views
Actions

bool literal

From cppreference.com
< cpp‎ | language
Revision as of 03:12, 23 January 2014 by D41D8CD98F (Talk | contribs)

Syntax

true (1)
false (2)

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.)

Example

std::cout << std::boolalpha
          << true << '\n'
          << false << '\n'
          << std::noboolalpha
          << true << '\n'
          << false << '\n';

Output:

true
false
1
0