O'Reilly logo

Exploring C++ 11, Second Edition by Ray Lischner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

EXPLORATION 12

image

Conditions and Logic

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 a stream to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required