2
Contributors
1
Reply
17
Views
2 Years
Discussion Span
Last Post by Schol-R-LEA
0

The built-in Boolean data type in C++, bool, is quite simple: it is a data type which can hold one of two values, true or false. It can be used to hold a truth value for comparisons:

bool overflow = false;

while (!overflow)
{
    //  ... do some things 

    overflow = (foo > bar);

    // ... do some more things
}

In this case, it is used becausse there are actions both before and after the place where the value is checked, so it cannot be in just the conditional of the while() loop.

It is most often used as the return value for a function that returns a true or false result based on some test.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.