2.5) Primitive Data Types of C++: Boolean Values
- Type
bool
represents a boolean (true or false) value - Literal values for
bool
are actually calledtrue
andfalse
(without quotes - they are not strings!) - Integer values are converted implicitly to boolean values where necessary: non-zero integers become
true
, zero becomesfalse
bool
values are converted implicitly to integers where necessary:true
becomes 1,false
becomes 0- When outputting a
bool
value to a stream,true
is output as 1 andfalse
is output as 0 (use theshowbool
manipulator to output the strings "true" or "false" instead)