Team LiB
Previous Section Next Section

Defined Terms

术语

abstract data type(抽象数据类型)

A data structure that uses encapsulation to hide its implementation, allowing programmers using the type to think abstractly about what the type does rather than concretely about how the type is represented. Classes in C++ can be used to define abstract data types.

使用封装来隐藏其实现的数据结构,允许使用类型的程序员抽象地考虑该类型做什么,而不是具体地考虑类型如何表示。C++ 中的类可用来定义抽象数据类型。

access label(访问标号)

A public or private label that defines whether the following members are accessible to users of the class or only to the friends and members of the class. Each label sets the access protection for the members declared up to the next label. Labels may appear multiple times within the class.

publicprivate 标号,指定后面的成员可以被类的使用者访问或者只能被类的友元和成员访问。每个标号为在该标号到下一个标号之间声明的成员设置访问保护。标号可以在类中出现多次。

class(类)

C++ mechanism for defining our own abstract data types. Classes may have data, function or type members. A class defines a new type and a new scope.

是 C++ 中定义抽象数据类型的一种机制,可以有数据、函数或类型成员。一个类定义了新的类型和新的作用域。

class declaration(类声明)

A class may be declared before it is defined. A class declaration is the keyword class (or struct) followed by the class name followed by a semicolon. A class that is declared but not defined is an incomplete type.

类可以在定义之前声明。类声明用关键字 class(或 struct)表示,后面加类名字和一个分号。已声明但没有定义的类是一个不完全的类型。

class keyword(class 关键字)

In a class defined following the class keyword, the initial implicit access label is private.

用在 class 关键字定义的类中,初始的隐式访问标号是 private

class scope(类作用域)

Each class defines a scope. Class scopes are more complicated than other scopesmember functions defined within the class body may use names that appear after the definition.

每个类定义一个作用域。类作用域比其他作用域复杂得多——在类的定义体内定义的成员函数可以使用出现在该定义之后的名字。

concrete class(具体类)

A class that exposes its implementation.

暴露其实现细节的类。

const member function(常量成员函数)

A member function that may not change an object's ordinary (i.e., neither static nor mutable) data members. The this pointer in a const member is a pointer to const. A member function may be overloaded based on whether the function is const.

一种成员函数,不能改变对象的普通(即,既不是 static 也不是 mutable)数据成员。const 成员中的 this 指针指向 const 对象。成员函数是否可以被重载取决于该函数是否为 const

constructor initializer list(构造函数初始化列表)

Specifies initial values of the data members of a class. The members are initialized to the values specified in the initializer list before the body of the constructor executes. Class members that are not initialized in the initializer list are implicitly initialized by using their default constructor.

指定类的数据成员的初始值。在构造函数体现执行前,用初始化列表中指定的值初始化成员。没有在初始化列表中初始化的类成员,使用它们的默认构造函数隐式初始化。

conversion constructor(转换构造函数)

A nonexplicit constructor that can be called with a single argument. A conversion constructor is used implicitly to convert from the argument's type to the class type.

可用单个实参调用的非 explicit 构造函数。隐式使用转换构造函数将实参的类型转换为类类型。

data abstraction(数据抽象)

Programming technique that focuses on the interface to a type. Data abstraction allows programmers to ignore the details of how a type is represented and to think instead about the operations that the type can perform. Data abstraction is fundamental to both object-oriented and generic programming.

注重类型接口的编程技术。数据抽象允许程序员忽略类型如何表示的细节,而只考虑该类型可以执行的操作。数据抽象是面向对象编程和泛型编程的基础。

default constructor(默认构造函数)

The constructor that is used when no initializer is specified.

没有指定初始化时使用的构造函数。

encapsulation(封装)

Separation of implementation from interface; encapsulation hides the implementation details of a type. In C++, encapsulation is enforced by preventing general user access to the private parts of a class.

实现与接口的分离。封闭隐藏了类型的实现细节。在 C++ 中,实施封装可以阻止普通用户访问类的 private 部分。

explicit constructor(显式构造函数)

Constructor that can be called with a single argument but that may not be used to perform an implicit conversion. A constructor is made explicit by prepending the keyword explicit to its declaration.

可以用单个实参调用但不能用于执行隐式转换的构造函数。通过将关键字 explicit 放在构造函数的声明之前而将其设置为 explicit

forward declaration(前向声明)

Declaration of an as yet undefined name. Most often used to refer to the declaration of a class that appears prior to the definition of that class. See incomplete type.

对尚未定义的名字的声明。大多用于引用出现在类定义之前的类声明。参见不完全类型。

friend(友元)

Mechanism by which a class grants access to its nonpublic members. Both classes and functions may be named as friends. friends have the same access rights as members.

类授权访问其非 public 成员的机制。类和函数都可以被指定为友元。友元拥有与成员一样的访问权。

incomplete type(不完全类型)

A type that has been declared but not yet defined. It is not possible use an incomplete type to define a variable or class member. It is legal to define references or pointers to incomplete types.

已声明但未定义的类型。不能使用不完全类型来定义变量或类成员。定义指向不完全类型的引用或指针是合法的。

member function(成员函数)

Class member that is a function. Ordinary member functions are bound to an object of the class type through the implicit this pointer. Static member functions are not bound to an object and have no this pointer. Member functions may be overloaded, provided that the versions of the function are distinguished by number or type of their parameters.

类的函数成员。普通成员函数通过隐式的 this 指针绑定到类类型的对象。static 成员函数不与对象绑定且没有 this 指针。成员函数可以被重载,只要该函数的版本可由形参的数目或类型来区别。

mutable data member(可变数据成员)

Data member that is never const, even when it is a member of a const object. A mutable member can be changed inside a const function.

一种永远也不能为 const 对象的数据成员,即使作为 const 对象的成员,也不能为 const 对象。mutable 成员可以在 const 函数中改变。

name lookup(名字查找)

The process by which the use of a name is matched to its corresponding declaration.

将名字的使用与其相应的声明相匹配的过程。

private members(私有成员)

Members defined after a private access label; accessible only to the friends and other class members. Data members and utility functions used by the class that are not part of the type's interface are usually declared private.

private 访问标号之后定义的成员,只能被友元和其他的类成员访问。类所使用的数据成员和实用函数在不作为类型接口的组成部分时,通常声明为 private

public members(公用成员)

Members defined after a public access label; public members are accessible to any user of the class. Ordinarily, only the functions that define the interface to the class should be defined in the public sections.

public 访问标号之后定义的成员,可被类的任意使用者访问。一般而言,只有定义类接口的函数应定义在 public 部分。

static member(静态成员)

Data or function member that is not a part of any object but is shared by all objects of a given class.

不是任意对象的组成部分、但由给定类的全体对象所共享的数据或函数成员。

struct keyword(struct 关键字)

In a class defined following the struct keyword, the initial implicit access label is public.

用在 struct 关键字定义的类中,初始的隐式访问标号为 public

synthesized default constructor(合成的默认构造函数)

The default constructor created (synthesized) by the compiler for classes that do not define any constructors. This constructor initializes members of class type by running that class's default constructor; members of built-in type are uninitialized.

编译器为没有定义任何构造函数的类创建(合成)的构造函数。这个构造函数通过运行该类的默认构造函数来初始化类类型的成员,内置类型的成员不进行初始化。

Team LiB
Previous Section Next Section