Bool Datatype

I Cant figure out even a single bit of the bool datatype even after reading over 10 books..... The problem is "is bool a built-in data-type in c++???"
"If it is then how do we declare a variable of bool datatype?????"
"Do we have signed/unsigned formats for this?????(I guess no , but still....)"
Bool is simply true or false. True is either explicitly given "true" or "false" or true is any non-0 number.

bool isTrue = 1;
bool isFalse = 0;
bool continue = true;
bool liveThroughFall = false;
bool life = true;

You use bool variables quite often when checking whether to continue loops, etc.
Note that

bool isTrue = 1;
bool isFalse = 0;


generate warnings with Visual C++ -- that there is a conversion from an int to a bool value. So if you're compiling under draconion coding conventions that require zero warning, these forms should be avoided. And if you do need to convert from an int with value 0 or 1 to a bool, you need (for some int "value")

bool isTrue = (0 != value);
Last edited on
Topic archived. No new replies allowed.