0
How to use bool and for what it's uses is?
2 odpowiedzi
+ 2
A bool (boolean) can take two different values, true or false. (The way it is defines in c++, false is 0 and true is any non-zero value.)
You can use a bool to represent anything that can only have two different values. For example, the presence or absence of a property.
A few logical operators:
not (!): !a is true if a is false
and (&&): (a && b) is true if both a and b are true
or (||): (a || b) is true if either a or b is true
xor (^): (a ^ b) is true if either a or b is true but not both
Note that comparison operators (like >= or !=) return a bool, and that the condition of if, while, etc. is a bool.
0
thanks a lot