Defined Terms
assertPreprocessor macro that takes a single expression, which it uses as a condition. If the preprocessor variable NDEBUG is not defined, then assert evaluates the condition. If the condition is false, assert writes a message and terminates the program.
blockA sequence of statements enclosed in curly braces. A block is a statement, so it can appear anywhere a statement is expected.
break statementTerminates the nearest enclosing loop or switch statement. Execution transfers to the first statement following the terminated loop or switch.
case labelIntegral constant value that follows the keyword case in a switch statement. No two case labels in the same switch statement may have the same value. If the value in the switch condition is equal to that in one of the case labels, control transfers to the first statement following the matched label. Execution continues from that point until a break is encountered or it flows off the end of the switch statement.
catch clauseThe catch keyword, an exception specifier in parentheses, and a block of statements. The code inside a catch clause does whatever is necessary to handle an exception of the type defined in its exception specifier.
compound statementSynonym for block.
continue statementTerminates the current iteration of the nearest enclosing loop. Execution transfers to the loop condition in a while or do or to the expression in the for header.
dangling elseColloquial term used to refer to the problem of how to process nested if statements in which there are more ifs than elses. In C++, an else is always paired with the closest preceding unmatched if. Note that curly braces can be used to effectively hide an inner if so that the programmer can control with which if a given else should be matched.
declaration statementA statement that defines or declares a variable. Declarations were covered in Chapter 2.
default labelThe switch case label that matches any otherwise unmatched value computed in the switch condition.
exception classesSet of classes defined by the standard library to be used to represent errors. Table 6.1 (p. 220) lists the general purpose exceptions.
exception handlerCode that deals with an exception raised in another part of the program. Synonym for catch clause.
exception specifierThe declaration of an object or a type that indicates the kind of exceptions a catch clause can handle.
expression statementAn expression followed by a semicolon. An expression statement causes the expression to be evaluated.
flow of controlExecution path through a program.
goto statementStatement that causes an unconditional transfer of control to a specified labeled statement elsewhere in the program. gotos obfuscate the flow of control within a program and should be avoided.
if else statementConditional execution of code following the if or the else, depending on the truth value of the condition.
if statementConditional execution based on the value of the specified condition. If the condition is true, then the if body is executed. If not, control flows to the statement following the if.
labeled statementA statement preceded by a label. A label is an identifier followed by a colon.
null statementAn empty statement. Indicated by a single semicolon.
preprocessor macroFunction like facility defined by the preprocessor. assert is a macro. Modern C++ programs make very little use of the preprocessor macros.
raiseOften used as a synonym for throw. C++ programmers speak of "throwing" or "raising" an exception interchangably.
switch statementA conditional execution statement that starts by evaluating the expression that follows the switch keyword. Control passes to the labeled statement with a case label that matches the value of the expression. If there is no matching label, execution either branches to the default label, if there is one, or falls out of the switch if there is no default label.
terminateLibrary function that is called if an exception is not caught. Usually aborts the program.
throw expressionExpression that interrupts the current execution path. Each throw tHRows an object and transfers control to the nearest enclosing catch clause that can handle the type of exception that is thrown.
try blockA block enclosed by the keyword try and one or more catch clauses. If the code inside the try block raises an exception and one of the catch clauses matches the type of the exception, then the exception is handled by that catch. Otherwise, the exception is handled by an enclosing try block or the program terminates.
while loopControl statement that executes its target statement as long as a specified condition is true. The statement is executed zero or more times, depending on the truth value of the condition.