Namespaces
Variants
Views
Actions

bool literal

From cppreference.com
< cpp‎ | language
Revision as of 10:56, 28 March 2014 by Pchriste (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

[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