C++ Demystified(c) A Self-Teaching Guide
-
You can use nested if statements as an alternative to the logical And and Or operators.
-
An if statement can be nested in the else if or else part of an if / else if / else statement, as well as the if part.
-
With the logical And operator, both Boolean expressions have to be true for the overall Boolean expression to be true.
-
With the logical Or operator, both Boolean expressions have to be false for the overall Boolean expression to be false.
-
The logical Not operator reverses the truth of a Boolean expression, making a true expression false and a false expression true.
-
Assuming resident is a Boolean variable, if(resident) is the same as if(resident == true).
-
The logical Not operator is a unary rather than binary operator.
-
The logical Not operator has a higher precedence than the relational operators.
-
The logical And operator has a higher precedence than the logical Or operator.
-
A Boolean value of either true or false can be used following the case keyword in a switch statement since both true and false have corresponding integer values.
Категории