C++20 sections · 1024 units
Open in Course

The bool Type

Binary states

The bool type holds one of two values: true or false. It uses 1 byte of memory even though it only needs 1 bit to store the value. You use bool to store yes/no answers, flags, or the result of comparisons.

Example: bool isValid = true; or bool found = false;. In C++, true converts to 1 and false converts to 0 when used as numbers. Any non-zero value converts to true when used as a bool.