Difference between revisions of "cpp/language/bool literal"
From cppreference.com
D41D8CD98F (Talk | contribs) |
D41D8CD98F (Talk | contribs) m (wording) |
||
Line 7: | Line 7: | ||
{{sdsc end}} | {{sdsc end}} | ||
===Explanation=== | ===Explanation=== | ||
− | #boolean {{tt|true}} (a {{rlp|value_category|prvalue}} of type {{tt|bool}} | + | #boolean {{tt|true}} (a {{rlp|value_category|prvalue}} of type {{tt|bool}}, implicitly convertible to the value 1 of type {{tt|int}}.) |
− | #boolean {{tt|false}} (a prvalue of type {{tt|bool}} | + | #boolean {{tt|false}} (a prvalue of type {{tt|bool}}, implicitly convertible to the value 0 of type {{tt|int}}.) |
===Example=== | ===Example=== | ||
{{example|code= | {{example|code= |
Revision as of 03:12, 23 January 2014
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
std::cout << std::boolalpha << true << '\n' << false << '\n' << std::noboolalpha << true << '\n' << false << '\n';
Output:
true false 1 0