Team LiB
Previous Section Next Section

Defined Terms

术语

argument(实参)

A value passed to a function when it is called.

传递给被调用函数的值。

block(块)

Sequence of statements enclosed in curly braces.

花括号括起来的语句序列。

buffer(缓冲区)

A region of storage used to hold data. IO facilities often store input (or output) in a buffer and read or write the buffer independently of actions in the program. Output buffers usually must be explicitly flushed to force the buffer to be written. By default, reading cin flushes cout; cout is also flushed when the program ends normally.

一段用来存放数据的存储区域。IO 设备常存储输入(或输出)到缓冲区,并独立于程序动作对缓冲区进行读写。输出缓冲区通常必须显式刷新以强制输出缓冲区内容。默认情况下,读 cin 会刷新 cout;当程序正常结束时,cout 也被刷新。

built-in type(内置类型)

A type, such as int, defined by the language.

C++ 语言本身定义的类型,如 int

cerr

ostream object tied to the standard error, which is often the same stream as the standard output. By default, writes to cerr are not buffered. Usually used for error messages or other output that is not part of the normal logic of the program.

绑定到标准错误的 ostream 对象,这通常是与标准输出相同的流。默认情况下,输出 cerr 不缓冲,通常用于不是程序正常逻辑部分的错误信息或其他输出。

cin

istream object used to read from the standard input.

用于从标准输入中读入的 istream 对象。

class

C++ mechanism for defining our own data structures. The class is one of the most fundamental features in C++. Library types, such as istream and ostream, are classes.

用于自定义数据结构的 C++ 机制。类是 C++ 中最基本的特征。标准库类型,如 istreamostream,都是类。

class type

A type defined by a class. The name of the type is the class name.

由类所定义的类型,类型名就是类名。

clog

ostream object tied to the standard error. By default, writes to clog are buffered. Usually used to report information about program execution to a log file.

绑定到标准错误的 ostream 对象。默认情况下,写到 clog 时是带缓冲的。通常用于将程序执行信息写入到日志文件中。

comments(注释)

Program text that is ignored by the compiler. C++ has two kinds of comments: single-line and paired. Single-line comments start with a //. Everything from the // to the end of the line is a comment. Paired comments begin with a /* and include all text up to the next */.

编译器会忽略的程序文本。C++ 有单行注释和成对注释两种类型的注释。单行注释以 // 开头,从 // 到行的结尾是一条注释。成对注释以 /* 开始包括到下一个 */ 为止的所有文本。

condition(条件)

An expression that is evaluated as true or false. An arithmetic expression that evaluates to zero is false; any other value yields true.

求值为真或假的表达式。值为 0 的算术表达式是假,其他所有非 0 值都是真。

cout

ostream object used to write to the standard output. Ordinarily used to write the output of a program.

用于写入到标准输出的 ostream 对象,一般情况下用于程序的输出。

curly brace(花括号)

Curly braces delimit blocks. An open curly ({) starts a block; a close curly (}) ends one.

花括号对语句块定界。左花括号“{”开始一个块,右花括号“}”结束块。

data structure(数据结构)

A logical grouping of data and operations on that data.

数据及数据上操作的逻辑组合。

edit-compile-debug(编辑—编译—调试)

The process of getting a program to execute properly.

使得程序正确执行的过程。

end-of-file(文件结束符)

System-specific marker in a file that indicates that there is no more input in the file.

文件中与特定系统有关的标记,表示这个文件中不再有其他输入。

expression(表达式)
an

The smallest unit of computation. An expression consists of one or more operands and usually an operator. Expressions are evaluated to produce a result. For example, assuming i and j are ints, then i + j is an arithmetic addition expression d yields the sum of the two int values. Expressions are covered in more detail in Chapter 5.

最小的计算单元。表达式包含一个或多个操作数并经常含有一个操作符。表达式被求值并产生一个结果。例如,假定 ij 都为 int 型,则 i + j 是一个算术加法表达式并求这两个 int 值的和。表达式将在第五章详细介绍。

for statement(for 语句)

Control statement that provides iterative execution. Often used to step through a data structure or to repeat a calculation a fixed number of times.

提供迭代执行的控制语句,通常用于步进遍历数据结构或对一个计算重复固定次数。

function(函数)

A named unit of computation.

有名字的计算单元。

function body(函数体)

Statement block that defines the actions performed by a function.

定义函数所执行的动作的语句块。

function name(函数名)

Name by which a function is known and can be called.

函数的名字标识,函数通过函数名调用。

header(头文件)

A mechanism whereby the definitions of a class or other names may be made available to multiple programs. A header is included in a program through a #include directive.

使得类或其他名字的定义在多个程序中可用的一种机制。程序中通过 #include 指示包含头文件。

if statement(if 语句)

Conditional execution based on the value of a specified condition. If the condition is true, the if body is executed. If not, control flows to the statement following the else if there is one or to the statement following the if if there is no else.

根据指定条件的值执行的语句。如果条件为真,则执行 if 语句体;否则控制流执行 else 后面的语句,如果没有 else 将执行 if 后面的语句。

iostream(输入输出流)

library type providing stream-oriented input and output.

提供面向流的输入和输出的标准库类型。

istream(输入流)

Library type providing stream-oriented input.

提供面向流的输入的标准库类型。

library type(标准库类型)

A type, such as istream, defined by the standard library.

标准库所定义的类型,如 istream

main function(主函数)

Function called by the operating system when executing a C++ program. Each program must have one and only one function named main.

执行 C++ 程序时,操作系统调用的函数。每一个程序有且仅有一个主函数 main

manipulator(操纵符)

Object, such as std::endl, that when read or written "manipulates" the stream itself. Section A.3.1 (p. 825) covers manipulators in more detail.

在读或写时“操纵”流本身的对象,如 std::endlA.3.1 节详细讲述操纵符。

member function(成员函数)

Operation defined by a class. Member functions ordinarily are called to operate on a specific object.

类定义的操作。成员函数通常在特定的对象上进行操作。

method(方法)

Synonym for member function.

成员函数的同义词。

namespace(命名空间)

Mechanism for putting names defined by a library into a single place. Namespaces help avoid inadvertent name clashes. The names defined by the C++ library are in the namespace std.

将库所定义的名字放至单独一个地方的机制。命名空间有助于避免无意的命名冲突。C++ 标准库所定义的名字在命名空间 std 中。

ostream(输出流)

Library type providing stream-oriented output.

提供面向流的输出的库类型。

parameter list(形参表)

Part of the definition of a function. Possibly empty list that specifies what arguments can be used to call the function.

函数定义的组成部分。指明可以用什么参数来调用函数,可能为空。

preprocessor directive(预处理指示)

An instruction to the C++ preprocessor. #include is a preprocessor directive. Preprocessor directives must appear on a single line. We'll learn more about the preprocessor in Section 2.9.2.

C++ 预处理器的指示。#include 是一个预处理器指示。预处理器指示必须出现在单独的行中。第 2.9.2 节将对预处理器作详细的介绍。

return type(返回类型)

Type of the value returned by a function.

函数返回值的类型。

source file(源文件)

Term used to describe a file that contains a C++ program.

用来描述包含在 C++ 程序中的文件的术语。

standard error(标准错误)

An output stream intended for use for error reporting. Ordinarily, on a windowing operating system, the standard output and the standard error are tied to the window in which the program is executed.

用于错误报告的输出流。通常,在视窗操作系统中,将标准输出和标准错误绑定到程序的执行窗口。

standard input(标准输入)

The input stream that ordinarily is associated by the operating system with the window in which the program executes.

和程序执行窗口相关联的输入流,通常这种关联由操作系统设定。

standard library(标准库)

Collection of types and functions that every C++ compiler must support. The library provides a rich set of capabilities including the types that support IO. C++ programmers tend to talk about "the library," meaning the entire standard library or about particular parts of the library by referring to a library type. For example, programmers also refer to the "iostream library," meaning the part of the standard library defined by the iostream classes.

每个 C++ 编译器必须支持的类型和函数的集合。标准库提供了强大的功能,包括支持 IO 的类型。C++ 程序员谈到的“标准库”,是指整个标准库,当提到某个标准库类型时也指标准库中某个特定的部分。例如,程序员提到的“iostream 库”,专指标准库中由 iostream 类定义的那部分。

standard output(标准输出)

The output stream that ordinarily is associated by the operating system with the window in which the program executes.

和程序执行窗口相关联的输出流,通常这种关联由操作系统设定。

statement(语句)

The smallest independent unit in a C++ program. It is analogous to a sentence in a natural language. Statements in C++ generally end in semicolons.

C++ 程序中最小的独立单元,类似于自然语言中的句子。C++ 中的语句一般以分号结束。

std

Name of the namespace used by the standard library. std::cout indicates that we're using the name cout defined in the std namespace.

标准库命名空间的名字,std::cout 表明正在使用定义在 std 命名空间中的名字 cout

string literal(字符串字面值)

Sequence of characters enclosed in double quotes.

以双引号括起来的字符序列。

uninitialized variable(未初始化变量)

Variable that has no initial value specified. There are no uninitialized variables of class type. Variables of class type for which no initial value is specified are initialized as specified by the class definition. You must give a value to an uninitialized variable before attempting to use the variable's value. Uninitialized variables can be a rich source of bugs.

没有指定初始值的变量。类类型没有未初始化变量。没有指定初始值的类类型变量由类定义初始化。在使用变量值之前必须给未初始化的变量赋值。未初始化变量是造成bug的主要原因之一。

variable(变量)

A named object.

有名字的对象。

while statement(while语句)

An iterative control statement that executes the statement that is the while body as long as a specified condition is true. The body is executed zero or more times, depending on the truth value of the condition.

一种迭代控制语句,只要指定的条件为真就执行 while 循环体。while 循环体执行0次还是多次,依赖于条件的真值。

() operator[()操作符]

The call operator: A pair of parentheses "()" following a function name. The operator causes a function to be invoked. Arguments to the function may be passed inside the parentheses.

调用操作符。跟在函数名后且成对出现的圆括号。该操作符导致函数被调用,给函数的实参可在括号里传递。

++ operator(++操作符)

Increment operator. Adds one to the operand; ++i is equivalent to i = i+ 1.

自增操作符。将操作数加 1,++i 等价于 i = i + 1

+= operator(+= 操作符)

A compound assignment operator. Adds right-hand operand to the left and stores the result back into the left-hand operand; a += b is equivalent to a =a + b.

复合赋值操作符,将右操作数和左操作数相加,并将结果存储到左操作数中;a += b等价于 a = a + b

. operator(. 操作符)

Dot operator. Takes two operands: the left-hand operand is an object and the right is the name of a member of that object. The operator fetches that member from the named object.

点操作符。接受两个操作数:左操作数是一个对象,而右边是该对象的一个成员的名字。这个操作符从指定对象中取得成员。

:: operator(:: 操作符)

Scope operator. We'll see more about scope in Chapter 2. Among other uses, the scope operator is used to access names in a namespace. For example, std::cout says to use the name cout from the namespace std.

作用域操作符。在第二章中,我们将看到更多关于作用域的介绍。在其他的使用过程中,:: 操作符用于在命名空间中访问名字。例如,std::cout 表示使用命名空间 std 中的名字 cout

= operator(= 操作符)

Assigns the value of the right-hand operand to the object denoted by the left-hand operand.

表示把右操作数的值赋给左操作数表示的对象。

<< operator(<< 操作符)

Output operator. Writes the right-hand operand to the output stream indicated by the left-hand operand: cout << "hi" writes hi to the standard output. Output operations can be chained together: cout << "hi << "bye" writes hibye.

输出操作符。把右操作数写到左操作数指定的输出流:cout << "hi"hi 写入到标准输出流。输出操作可以链接在一起使用:cout << "hi << "bye" 输出 hibye

>> operator(>> 操作符)

Input operator. Reads from the input stream specified by the left-hand operand into the right-hand operand: cin >> i reads the next value on the standard input into i. Input operations can be chained together: cin >> i >> j reads first into i and then into j.

输入操作符。从左操作数指定的输入流读入数据到右操作数:cin >> i 把标准输入流中的下一个值读入到 i 中。输入操作能够链接在一起使用:cin >> i >> j 先读入 i 然后再读入 j

== operator(== 操作符)

The equality operator. Tests whether the left-hand operand is equal to the right-hand.

等于操作符,测试左右两边的操作数是否相等。

!= operator(!=操作符)

Assignment operator. Tests whether the left-hand operand is not equal to the right-hand.

不等于操作符。测试左右两边的操作数是否不等。

<= operator(<= 操作符)

The less-than-or-equal operator. Tests whether the left-hand operand is less than or equal to the right-hand.

小于或等于操作符。测试左操作数是否小于或等于右操作数。

< operator(< 操作符)

The less-than operator. Tests whether the left-hand operand is less than the right-hand.

小于操作符。测试左操作数是否小于右操作数。

>= operator(>= 操作符)

Greater-than-or-equal operator. Tests whether the left-hand operand is greater than or equal to the right-hand.

大于或等于操作符。测试左操作数是否大于或等于右操作数。

> operator(> 操作符)

Greater-than operator. Tests whether the left-hand operand is greater than the right-hand.

大于操作符。测试左操作数是否大于右操作数。

Team LiB
Previous Section Next Section