bool literal
From cppreference.com
Syntax
true | (1) | ||||||||
false | (2) | ||||||||
Explanation
- boolean
true
(a prvalue of typebool
, implicitly convertible to the value 1 of typeint
.) - boolean
false
(a prvalue of typebool
, implicitly convertible to the value 0 of typeint
.)
Example
Run this code
#include <iostream> int main() { std::cout << std::boolalpha << true << '\n' << false << '\n' << std::noboolalpha << true << '\n' << false << '\n'; }
Output:
true false 1 0