Team LiB
Previous Section Next Section

Defined Terms

术语

assert

Preprocessor 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.

一种预处理宏,使用单个表达式作为断言条件。如果预处理变量 NDEBUG 没有定义,则 assert 将求解它的条件表达式。若条件为 falseassert 输出信息并终止程序的执行。

block(块)

A sequence of statements enclosed in curly braces. A block is a statement, so it can appear anywhere a statement is expected.

包含在一对花括号里的语句序列。在语法上,块就是单语句,可出现在任何单语句可以出现的地方。

break statement(break 语句)

Terminates the nearest enclosing loop or switch statement. Execution transfers to the first statement following the terminated loop or switch.

一种语句,能够终止最近的循环或者 switch 语句的执行,将控制权交给被终止的循环或者 switch 后的第一条语句。

case label(case 标号)

Integral 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.

switch 语句中跟在关键字 case 后的整型常量值。在同一个 switch 结构中不能有任何两个标号拥有相同的常量值。如果 switch 条件表达式的值与其中某个标号的值相等,则控制权转移到匹配标号后面的第一条语句,从这种语句开始依次继续各个语句,直到遇到 break 或者到达 switch 结尾为止。

catch clause(catch 子句)

The 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.

一种语句,包括关键字 catch、圆括号内的异常说明符以及一个块语句。catch 子句中的代码实现某种异常的处理,该异常的处理,该异常由圆括号内的异常说明符定义。

compound statement(复合语句)

Synonym for block.

块的同义词。

continue statement(continue 语句)

Terminates 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.

一种语句,能够结束最近的循环结构的当次循环迭代,将控制流转移到 whiledo 的循环条件表达式,或者 for 语句头中第三个表达式。

dangling else(悬垂 else)

Colloquial 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.

一个通俗术语,指出如何处理嵌套 if 语句中 if 多于 else 时发生的二义性问题。C++ 中,else 总是与最近的未匹配的 if 配对。注意使用花括号能有效地隐藏内层 if,使程序员可以控制给定的 else 与哪个 if 相匹配。

declaration statement(声明语句)

A statement that defines or declares a variable. Declarations were covered in Chapter 2.

定义或者声明变量的语句。声明已在第二章中介绍。

default label(default 标号)

The switch case label that matches any otherwise unmatched value computed in the switch condition.

switch 语句中的一种标号,当计算 switch 条件所得的值与所有 case 标号的值都不匹配时,则执行 default 标号关联的语句。

exception classes(异常类)

Set of classes defined by the standard library to be used to represent errors. Table 6.1 (p. 220) lists the general purpose exceptions.

标准库定义的一组描述程序错误的类。表 6.1 列出了常见的异常。

exception handler(异常处理代码)

Code that deals with an exception raised in another part of the program. Synonym for catch clause.

一段代码,用于处理程序某个部分引起的异常。是 catch 子句的同义词。

exception specifier(异常说明符)

The declaration of an object or a type that indicates the kind of exceptions a catch clause can handle.

对象或类型的声明,用于指出当前的 catch 能处理的异常类型。

expression statement(表达式语句)

An expression followed by a semicolon. An expression statement causes the expression to be evaluated.

一种语句,由后接分号的表达式构成。表达式语句用于表达式的求解。

flow of control(控制流)

Execution path through a program.

程序的执行路径。

goto statement(goto 语句)

Statement 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.

一种语句,能够使程序控制流程无条件跳转到指定标号语句。goto 扰乱了程序内部的控制流,应尽可能避免使用。

if else statement(if else 语句)

Conditional execution of code following the if or the else, depending on the truth value of the condition.

一种语句,有条件地执行 ifelse 后的代码,如何执行取决于条件表达式的真值。

if statement(if 语句)

Conditional 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.

基于指定条件值的条件分支语句。如果条件为真,则执行 if 语句体;否则,控制流转到 if 后面的语句。

labeled statement(带标号的语句)

A statement preceded by a label. A label is an identifier followed by a colon.

以标号开头的语句。标号是后面带一个冒号的标识符。

null statement(空语句)

An empty statement. Indicated by a single semicolon.

空白的语句。其语法形式为单个分号。

preprocessor macro(预处理宏)

Function like facility defined by the preprocessor. assert is a macro. Modern C++ programs make very little use of the preprocessor macros.

与预处理器定义的设施相似的函数。assert 是一个宏。现代 C++ 程序很少使用预处理宏。

raise(引发)

Often used as a synonym for throw. C++ programmers speak of "throwing" or "raising" an exception interchangably.

常用作 throw 的同义词。C++ 程序员所说的“抛出(throwing)”或者“引发(raising)”异常表示一样的含义。

switch statement(switch 语句)

A 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.

从计算关键字 switch 后面的表达式开始执行的条件分支语句。程序的控制流转跳到与表达式值匹配的 case 标号所标记的标号语句。如果没有匹配的标号,则执行 default 标号标记的分支,如果没有提供 default 分支则结束 switch 语句的执行。

terminate

Library function that is called if an exception is not caught. Usually aborts the program.

异常未被捕获时调用的标准库函数。通常会终止程序的执行。

throw expression(throw 表达式)

Expression 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.

中断当前执行路径的表达式。每个 throw 都会抛出一个对象,并将控制转换到最近的可处理该类型异常的 catch 子句。

try block(try 块)

A 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.

跟在关键字 try 后面的块,以及一个或多个 catch 子句。如果 try 块中的代码产生了异常,而且该异常类型与其中某个 catch 子句匹配,则执行这个 catch 子句的语句处理这个异常。否则,异常将由外围 try 块处理,或者终止程序。

while loop(while 循环)

Control 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.

当指定条件为 true 时,执行目标代码的控制语句。根据条件的真值,目标代码可能执行零次或多次。

Team LiB
Previous Section Next Section