![]() |
Booleans in C++ |
bool
type for boolean values.
Booleans, for those not familiar with them, are variables that take
on one of two values, true
and false
.
Booleans can be compared to each other and to these constants (although
there are some dangers in doing these comparisons with our
implementation), can be tested and used in if
conditional
statements or while
loops, and can be assigned to the
result of comparisons,
i.e. bool b = (x == y);
for later use.
MSVC 5.0 and g++
provide this bool
type
built in. If you are using these platforms, you don't need this file,
but it knows how to recognize these systems, so using it won't hurt
anything either. If you are using another platform, you should copy
this file:
#include "bool.h"
from
each of your .cpp
files.
If your compiler supports another form of boolean (i.e. the
Boolean
type with constants TRUE
and
FALSE
found on some Mac compilers), do not use
it. You need to use the new-style booleans provided here
(bool
type and constants true
and
false
), or else your code will not work for us and you
will be penalized. Ask your TA if you have any questions.
Any questions or problems with the code here should be directed to me.
Have fun!
Andy