© Ray Lischner 2020
R. LischnerExploring C++20https://doi.org/10.1007/978-1-4842-5961-0_12

12. Conditions and Logic

Ray Lischner1 
(1)
Ellicott City, MD, USA
 

You first met the bool type in Exploration 2. This type has two possible values: true and false, which are reserved keywords (unlike in C). Although most Explorations have not needed to use the bool type, many have used logical expressions in loop and if-statement conditions. This Exploration examines the many aspects of the bool type and logical operators.

I/O and bool

C++ I/O streams permit reading and writing bool values. By default, streams treat them as numeric values: true is 1 and false is 0. The manipulator std::boolalpha (declared in <ios>, so you get it for free from <iostream>) tells ...

Get Exploring C++20: The Programmer's Introduction to C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.