- In C++, a decision can be base don any expression that can be evaluated as zero or nonzero -- if the expression evaluates to zero, it's treated as false; if the expression evaluate to nonzero, it's treated as true
- C++ provide the data type "bool" for Boolean variables that can hold only the values "true" and "false" -- each of these is a C++ keyword.
- The UML decision symbol (diamond) indicates that a decision is to be made. The workflow continues along a path determined by the symbol's associated guard conditions which can be true or false.
- Each transition arrow emerging from a decision symbol has a guard condition (specified in square brackets next to the arrow). If a guard condition is true, the workflow enters the action state to which the transition arrow points.
- The "if...else" double-selection statement allows yo to specify an action to perform when the condition is true and another action when the conditions is false
- A program can test multiple cases by placing "if...else" statements insider other "if. . .else" statement to create nested "if. . .else" statements
- Enclosing control-statement bodies in braces ( { and } ) avoids a logic error called the "dangling-else" problem
- Statements contained in a pair of braces form a block. A block can be placed anywhere in a function that a single statement can be placed
- Syntax errors are caught by the compiler
- A logic error has its effect at execution time
- A fatal logic error causes a program to fail and terminate prematurely
- A nonfatal logic error allows a program to continue executing but causes it to produce incorrect results.
- Just as a block can be placed anywhere a single statement can be placed, it's also possible to have an empty statement, ; where a statement would normally be
- The conditional operator, ?: is C++ only ternary operator. Together the operands and the ?: symbol form a conditional expression.
- The first operand (to the left of the ?) is a condition, the second operand (between the ? and :) is the value of the conditional expression if the condition is true and the third operand (to the right of the :) is the value of the conditional expression if the condition is false.