Team LiB
Previous Section Next Section

Defined Terms

术语

access labels(访问标号)

Members in a class may be defined to be private, which protects them from access from code that uses the type. Members may also be defined as public, which makes them accessible code throughout the program.

类的成员可以定义为 private,这能够防止使用该类型的代码访问该成员。成员还可以定义为 public,这将使该整个程序中都可访问成员。

address(地址)

Number by which a byte in memory can be found.

一个数字,通过该数字可在存储器上找到一个字节。

arithmetic types(算术类型)

The arithmetic types represent numbers: integers and floating point. There are three types of floating point values: long double, double, and float. These represent extended, double, and single precision values. It is almost always right to use double. In particular, float is guaranteed only six significant digits too small for most calculations. The integral types include bool, char, wchar_t, short, int, and long. Integer types can be signed or unsigned. It is almost always right to avoid short and char for arithmetic. Use unsigned for counting. The bool type may hold only two values: true or false. The whcar_t type is intended for characters from an extended character set; char type is used for characters that fit in 8 bits, such as Latin-1 or ASCII.

表示数值即整数和浮点数的类型。浮点型值有三种类型:long doubledoublefloat,分别表示扩展精度值、双精度值和单精度值。一般总是使用 double 型。特别地,float 只能保证六位有效数字,这对于大多数的计算来说都不够。整型包括 boolcharwchar_tshortintlong 。整型可以是带符号或无符号的。一般在算术计算中总是避免使用 shortcharunsigned 可用于计数。bool 类型只有 truefalse 两个值。wchar_t 类型用于扩展字符集的字符;char 类型用于适合 8 个位的字符,比如 Latin-1 或者 ASCII。

array(数组)

Data structure that holds a collection of unnamed objects that can be accessed by an index. This chapter introduced the use of character arrays to hold string literals. Chapter 4 will discuss arrays in much more detail.

存储一组可通过下标访问的未命名对象的数据结构。本章介绍了存储字符串字面值的字符数组。第四章将会更加详细地介绍数组。

byte(字节)

Typically the smallest addressable unit of memory. On most machines a byte is 8 bits.

最小的可寻址存储单元。大多数的机器上一个字节有 8 个位(bit)。

class(类)

C++ mechanism for defining data types. Classes are defined using either the class or struct keyword. Classes may have data and function members. Members may be public or private. Ordinarily, function members that define the operations on the type are made public; data members and functions used in the implementation of the class are made private. By default, members in a class defined using the class keyword are private; members in a class defined using the struct keyword are public.

C++ 中定义数据类型的机制。类可以用 classstruct 关键字定义。类可以有数据和函数成员。成员可以是 publicprivate。一般来说,定义该类型的操作的函数成员设为 public ;用于实现该类的数据成员和函数设为 private。默认情况下,用 class 关键字定义的类其成员为 private ,而用 struct 关键字定义的类其成员为 public

class member(类成员)

A part of a class. Members are either data or operations.

类的一部分,可以是数据或操作。

compound type(复合类型)

A type, such as a reference, that is defined in terms of another type. Chapter 4 covers two additional compound types: pointers and arrays.

用其他类型定义的类型,如引用。第四章将介绍另外两种复合类型:指针和数组。

const reference(const 引用)

A reference that may be bound to a const object, a nonconst object, or to an rvalue. A const reference may not change the object to which it refers.

可以绑定到 const 对象、非 const 对象或右值的引用。const 引用不能改变与其相关联的对象。

constant expression(常量表达式)

An integral expression whose value can be evaluated at compile-time.

值可以在编译时计算出来的整型表达式。

constructor(构造函数)

Special member function that is used to initialize newly created objects. The job of a constructor is to ensure that the data members of an object have safe, sensible initial values.

用来初始化新建对象的特殊成员函数。构造函数的任务是保证对象的数据成员拥有可靠且合理的初始值。

copy-initialization(复制初始化)

Form of initialization that uses the = symbol to indicate that variable should be initialized as a copy of the initializer.

一种初始化形式,用“=”表明变量应初始化为初始化式的副本。

data member(数据成员)

The data elements that constitute an object. Data members ordinarily should be private.

组成对象的数据元素。数据成员一般应设为私有的。

declaration(声明)

Asserts the existence of a variable, function, or type defined elsewhere in the program. Some declarations are also definitions; only definitions allocate storage for variables. A variable may be declared by preceeding its type with the keyword extern. Names may not be used until they are defined or declared.

表明在程序中其他地方定义的变量、函数或类型的存在性。有些声明也是定义。只有定义才为变量分配存储空间。可以通过在类型前添加关键字 extern 来声明变量。名字直到定义或声明后才能使用。

default constructor(默认构造函数)

The constructor that is used when no explicit values are given for an initializer of a class type object. For example, the default constructor for string initializes the new string as the empty string. Other string constructors initialize the string with characters specified when the string is created.

在没有为类类型对象的初始化式提供显式值时所使用的构造函数。例如,string 类的默认构造函数将新建的 string 对象初始化为空 string,而其他构造函数都是在创建 string 对象时用指定的字符去初始化 string 对象。

definition(定义)

Allocates storage for a variable of a specified type and optionally initializes the variable. Names may not be used until they are defined or declared.

为指定类型的变量分配存储空间,也可能可选地初始化该变量。名字直到定义或声明后才能使用。

direct-initialization(直接初始化)

Form of initialization that places a comma-separated list of initializers inside a pair of parentheses.

一种初始化形式,将逗号分隔的初始化式列表放在圆括号内。

enumeration(枚举)

A type that groups a set of named integral constants.

将一些命名整型常量聚成组的一种类型。

enumerator(枚举成员)

The named members of an enumeration. Each enumerator is initialized to an integral value and the value of the enumerator is const. Enumerators may be used where integral constant expressions are required, such as the dimension of an array definition.

枚举类型的有名字的成员。每个枚举成员都初始化为整型值且值为 const。枚举成员可用在需要整型常量表达式的地方,比如数组定义的维度。

escape sequence(转义字符)

Alternative mechanism for representing characters. Usually used to represent nonprintable characters such as newline or tab. An escape sequence is a backslash followed by a character, a three-digit octal number, or a hexadecimal number. The escape sequences defined by the language are listed on page 40. Escape sequences can be used as a literal character (enclosed in single quotes) or as part of a literal string (enclosed in double quotes).

一种表示字符的可选机制。通常用于表示不可打印字符如换行符或制表符。转义字符是反斜线后面跟着一个字符、一个 3 位八进制数或一个十六进制的数。C++ 语言定义的转义字符列在第 2.2 节。转义字符还可用作字符字面值(括在单引号里)或用作字符串字面值的一部分(括在双引号里)。

global scope(全局作用域)

Scope that is outside all other scopes.

位于任何其他作用域外的作用域。

header(头文件)

A mechanism for making class definitions and other declarations available in multiple source files. User-defined headers are stored as files. System headers may be stored as files or in some other system-specific format.

使得类的定义和其他声明在多个源文件中可见的一种机制。用户定义的头文件以文件方式保存。系统头文件可能以文件方式保存,也可能以系统特有的其他格式保存。

header guard(头文件保护符)

The preprocessor variable defined to prevent a header from being included more than once in a single source file.

为防止头文件被同一源文件多次包含而定义的预处理器变量。

identifier(标识符)

A name. Each identifier is a nonempty sequence of letters, digits, and underscores that must not begin with a digit. Identifiers are case-sensitive: Upper- and lowercase letters are distinct. Identifiers may not use C++ keywords. Identifiers may not contain two adjacent underscores nor may they begin with an underscore followed by a uppercase letter.

名字。每个标识符都是字母、数字和下划线的非空序列,且序列不能以数字开头。标识符是大小写敏感的:大写字母和小写字母含义不同。标识符不能使用C++中的关键字,不能包含相邻的下划线,也不能以下划线后跟一个大写字母开始。

implementation(实现)

The (usually private) members of a class that define the data and any operations that are not intended for use by code that uses the type. The istream and ostream classes, for example, manage an IO buffer that is part of their implementation and not directly accessible to users of those classes.

定义数据和操作的类成员(通常为 private),这些数据和操作并非为使用该类型的代码所用。例如,istreamostream 类管理的 IO 缓冲区是它们的实现的一部分,但并不允许这些类的使用者直接访问。

initialized(已初始化的)

A variable that has an initial value. An initial value may be specified when defining a variable. Variables usually should be initialized.

含有初始值的变量。当定义变量时,可指定初始值。变量通常要初始化。

integral types(整型)

See arithmetic type.

见 arithmetic type。

interface(接口)

The operations supported by a type. Well-designed classes separate their interface and implementation, defining the interface in the public part of the class and the implementation in the private parts. Data members ordinarily are part of the implementation. Function members are part of the interface (and hence public) when they are operations that users of the type are expected to use and part of the implementation when they perform operations needed by the class but not defined for general use.

由某种类型支持的操作。设计良好的类分离了接口和实现,在类的 public 部分定义接口,private 部分定义实现。数据成员一般是实现的一部分。当函数成员是期望该类型的使用者使用的操作时,函数成员就是接口的一部分(因此为 public);当函数成员执行类所需要的、非一般性使用的操作时,函数成员就是实现的一部分。

link(链接)

Compilation step in which multiple object files are put together to form an executable program. The link step resolves interfile dependencies, such as linking a function call in one file to a function definition contained in a second file.

一个编译步骤,此时多个目标文件放置在一起以形成可执行程序。链接步骤解决了文件间的依赖,如将一个文件中的函数调用链接到另一个文件中的函数定义。

literal constant(字面值常量)

A value such as a number, a character, or a string of characters. The value cannot be changed. Literal characters are enclosed in single quotes, literal strings in double quotes.

诸如数、字符或字符串的值,该值不能修改。字面值字符用单引号括住,而字面值字符串则用双引号括住。

local scope(局部作用域)

Term used to describe function scope and the scopes nested inside a function.

用于描述函数作用域和函数内嵌套的作用域的术语。

lvalue(左值)

A value that may appear on the left-hand of an assignment. A nonconst lvalue may be read and written.

可以出现在赋值操作左边的值。非 const 左值可以读也可以写。

magic number(魔数)

A literal number in a program whose meaning is important but not obvious. It appears as if by magic.

程序中意义重要但又不明显的字面值数字。它的出现好像变魔术一般。

nonconst reference(非 const 引用)

A reference that may be bound only to a nonconst lvalue of the same type as the reference. A nonconst reference may change the value of the underlying object to which it refers.

只能绑定到与该引用同类型的非 const 左值的引用。非 const 引用可以修改与其相关联的对象的值。

nonprintable character(非打印字符)

A character with no visible representation, such as a control character, a backspace, newline, and so on.

不可见字符。如控制符、回退删除符、换行符等。

object(对象)

A region of memory that has a type. A variable is an object that has a name.

具有类型的一段内存区域。变量就是一个有名字的对象。

preprocessor(预处理器)

The preprocessor is a program that runs as part of compilation of a C++ program. The preprocessor is inherited from C, and its uses are largely obviated by features in C++. One essential use of the preprocessor remains: the #include facility, which is used to incorporate headers into a program.

预处理器是作为 C++ 程序编译的一部分运行的程序。预处理器继承于 C 语言,C++ 的特征大量减少了它的使用,但仍保存了一个很重要的用法:#include 设施,用来把头文件并入程序。

private member(私有成员)

Member that is inaccessible to code that uses the class.

使用该类的代码不可访问的成员。

public member(公用成员)

Member of a class that can be used by any part of the program.

可被程序的任何部分使用的类成员。

reference(引用)

An alias for another object. Defined as follows:

对象的别名。定义如下:

     type &id = object;

Defines id to be another name for object. Any operation on id is translated as an operation on object.

定义 idobject 的另一名字。任何对 id 的操作都会转变为对 object 的操作。

run time(运行时)

Refers to the time during which the program is executing.

指程序正执行的那段时间。

rvalue(右值)

A value that can be used as the right-hand, but not left-hand side of an assignment. An rvalue may be read but not written.

可用于赋值操作的右边但不能用于左边的值。右值只能读而不能写。

scope(作用域)

A portion of a program in which names have meaning. C++ has several levels of scope:

程序的一部分,在其中名字有意义。C++ 含有下列几种作用域:

global names defined outside any other scope.

全局——名字定义在任何其他作用域外。

class names defined by a class.

——名字由类定义。

namespace names defined within a namespace.

命名空间——名字在命名空间中定义。

local names defined within a function.

局部——名字在函数内定义。

block names defined within a block of statements, that is, within a pair of curly braces.

——名字定义在语句块中,也就是说,定义在一对花括号里。

statement names defined within the condition of a statement, such as an if, for, or while.

语句——名字在语句( 如ifwhilefor 语句)的条件内定义。

Scopes nest. For example, names declared at global scope are accessible in function and statement scope.

作用域可嵌套。例如,在全局作用域中声明的名字在函数作用域和语句作用域中都可以访问。

separate compilation(分别编译)

Ability to split a program into multiple separate source files.

将程序分成多个分离的源文件进行编译。

signed(带符号型)

Integer type that holds negative or positive numbers, including zero.

保存负数、正数或零的整型。

statically typed(静态类型的)

Term used to refer to languages such as C++ that do compile-time type checking. C++ verifies at compile-time that the types used in expressions are capable of performing the operations required by the expression.

描述进行编译时类型检查的语言(如 C++)的术语。C++ 在编译时验证表达式使用的类型可以执行该表达式需要的操作。

struct

Keyword that can be used to define a class. By default, members of a struct are public until specified otherwise.

用来定义类的关键字。除非有特殊的声明,默认情况下 struct 的成员都为公用的。

type-checking(类型检查)

Term used to describe the process by which the compiler verifies that the way objects of a given type are used is consistent with the definition of that type.

编译器验证给定类型的对象的使用方式是否与该类型的定义一致,描述这一过程的术语。

type specifier(类型说明符)

The part of a definition or declaration that names the type of the variables that follow.

定义或声明中命名其后变量的类型的部分。

typedef

Introduces a synonym for some other type. Form:

为某种类型引入同义词。格式:

     typedef type synonym;

defines synonym as another name for the type named type.

定义 synonym 为名为 type 的类型的另一名字。

undefined behavior(未定义行为)

A usage for which the language does not specify a meaning. The compiler is free to do whatever it wants. Knowingly or unknowingly relying on undefined behavior is a great source of hard-to-track run-time errors and portability problems.

语言没有规定其意义的用法。编译器可以自由地做它想做的事。有意或无意地依赖未定义行为将产生大量难于跟踪的运行时错误和可移值性问题。

uninitialized(未初始化的)

Variable with no specified initial value. An uninitialized variable is not zero or "empty;" instead, it holds whatever bits happen to be in the memory in which it was allocated. Uninitialized variables are a great source of bugs.

没有指定初始值的变量。未初始化变量不是0也不是“空”,相反,它会保存碰巧遗留在分配给它的内存里的任何位。未初始化变量会产生很多错误。

unsigned(无符号型)

Integer type that holds values greater than or equal to zero.

保存大于等于零的值的整型。

variable initialization(变量初始化)

Term used to describe the rules for initializing variables and array elements when no explicit initializer is given. For class types, objects are initialized by running the class's default constructor. If there is no default constructor, then there is a compile-time error: The object must be given an explicit initializer. For built-in types, initialization depends on scope. Objects defined at global scope are initialized to 0; those defined at local scope are uninitialized and have undefined values.

描述当没有给出显式初始化式时初始化变量或数组元素的规则的术语。对类类型来说,通过运行类的默认构造函数来初始化对象。如果没有默认构造函数,那么将会出现编译时错误:必须要给对象指定显式的初始化式。对于内置类型来说,初始化取决于作用域。定义在全局作用域的对象初始化为 0,而定义在局部作用域的对象则未初始化,拥有未定义值。

void type(空类型)

Special-purpose type that has no operations and no value. It is not possible to define a variable of type void. Most commonly used as the return type of a function that does not return a result.

用于特殊目的的没有操作也没有值的类型。不可能定义一个 void 类型的变量。最经常用作不返回结果的函数的返回类型。

word(字)

The natural unit of integer computation on a given machine. Usually a word is large enough to hold an address. Typically on a 32-bit machine machine a word is 4 bytes.

机器上的自然的整型计算单元。通常一个字足以容纳一个地址。一般在 32 位的机器上,机器字长为 4 个字节。

Team LiB
Previous Section Next Section