Lecture 2 - Slide 3 : 29
Booleans
There is a type
bool
in C++
Boolean constants
true
and
false
The C++ Prog. Lang. (3. edition)
:
Page 71
The C++ Prog. Lang. (4. edition)
: Page 139
Type
bool
in relation to other fundamental types
Boolean values are converted implicitly to integers in arithmetic and logical expressions:
false
to 0 and
true
to 1.
Integers can be converted implicitly to booleans: 0 to
false
, other values to
true
.
Pointers can implicitly be converted to boolean values as well
Under the hood the well-known C boolean conventions still apply