Team LiB
Previous Section Next Section

Defined Terms

术语

abstract base class(抽象基类)

Class that has or inherits one or more pure virtual functions. It is not possible to create objects of an abstract base-class type. Abstract base classes exist to define an interface. Derived classes will complete the type by defining type-specific implementations for the pure virtuals defined in the base.

具有或继承了一个或多个纯虚函数的类。不能创建抽象基类类型的对象。抽象基类的存在定义了一个接口,派生类将为基类中定义的纯虚函数定义特定类型的实现,以完成类型。

base class(基类)

Class from which another class inherits. The members of the base class become members of the derived class.

从中派生其他类的类。基类的成员成为派生类的成员。

class derivation list(类派生列表)

Used by a class definition to indicate that the class is a derived class. A derivation list includes an optional access level and names the base class. If no access label is specified, the type of inheritance depends on the keyword used to define the derived class. By default, if the derived class is defined with the struct keyword, then the base class is inherited publicly. If the class is defined using the class keyword, then the base class is inherited privately.

类定义用它指出类是派生类。派生列表包含可选的访问级别和基类的名字,如果不指定访问标号,继承的类型取决于用来定义派生类的保留字,默认情况下,如果派生类用保留字 struct 定义,则仅有继承基类,如果派生类用保留字 class 定义,则私有继承基类。

derived class(派生类)

A class that inherits from another class. The members of the base class are also members of the derived class. A derived class can redefine the members of its base and can define new members. A derived-class scope is nested in the scope of its base class(es), so the derived class can access members of the base class directly. Members defined in the derived with the same name as members in the base hide those base members; in particular, member functions in the derived do not overload members from the base. A hidden member in the base can be accessed using the scope operator.

继承了其他类的类。基类的成员也是派生类的成员,派生类可以重定义其基类的成员还可以定义新成员。派生类作用域嵌套的基类作用域中,因此派生类可以直接访问基类的成员。派生类中定义的与基类成员同名的成员屏蔽基类成员,具体而言,派生类中的成员函数不重载基类成员。基类中的被屏蔽成员可以用作用域操作符访问。

direct base class(直接基类)

Synonym for immediate base class.

immediate base class 的同义词。

dynamic binding(动态绑定)

Delaying until run time the selection of which function to run. In C++, dynamic binding refers to the run-time choice of which virtual function to run based on the underlying type of the object to which a reference or pointer is bound.

延迟到运行时才选择运行哪个函数。在 C++ 中,动态绑定指的是在运行时基于引用或指针绑定的对象的基础类型而选择运行哪个 virtual 函数。

dynamic type(动态类型)
T

ype at run time. Pointers and references to base-class types can be bound to objects of derived type. In such cases the static type is reference (or pointer) to base, but the dynamic type is reference (or pointer) to derived.

运行时类型。基类类型的指针和引用可以绑定到派生类型的对象,在这种情况下,静态类型是基类引用(或指针),但动态类型是派生类引用(或指针)。

handle class(句柄类)

Class that provides an interface to another class. Commonly used to allocate and manage a pointer to an object of an inheritance hierarchy.

提供到其他类的接口的类。一般用于分配和管理继承层次对象的指针。

immediate base class(直接基类)

A base class from which a derived class inherits directly. The immediate base is the class named in the derivation list. The immediate base may itself be a derived class.

被派生类直接继承的基类。直接基类是在派生列表中指定的基类,直接基类本身可以是派生类。

indirect base class(间接基类)

A base class that is not immediate. A class from which the immediate base class inherits, directly or indirectly, is an indirect base class to the derived class.

非直接基类。直接基类直接或间接继承的类是派生类的间接基类。

inheritance hierarchy(继承层次)

Term used to describe the relationships among classes related by inheritance that share a common base class.

描述因共享公共基类的继承而相关联的类之间关系的术语。

object-oriented programming(面向对象编程)

Term used to describe programs that use data abstraction, inheritance, and dynamic binding.

描述使用数据抽象、继承和动态绑定的程序的术语。

polymorphism(多态性)

A term derived from a Greek word that means "many forms." In object-oriented programming, polymorphism refers to the ability to obtain type-specific behavior based on the dynamic type of a reference or pointer.

从意为“多种形态”的希腊单词派生的术语。在面向对象编程中,多态性指的是基于引用或指针的动态类型获得类型明确的行为的能力。

private inheritance(私有继承)

A form of implementation inheritance in which the public and protected members of a private base class are private in the derived.

实现继承的一种形式,在这种形式中,private 基类的 publicprotected 成员在派生类中均为 private

protected access label(受保护访问标号)

Members defined after a protected label may be accessed by class members and friends and by the members (but not friends) of a derived class. protected members are not accessible to ordinary users of the class.

定义在 protected 标号之后的成员可以被类成员、友元和派生类成员(非友元)访问。类的普通用户不能访问 protected 成员。

protected inheritance(受保护继承)

In protected inheritance the protected and public members of the base class are protected in the derived class.

在受保护继承中,基类的 protectedpublic 成员在派生类中均为 protected

public inheritance(公有继承)

The public interface of the base class is part of the public interface of the derived class.

基类的 public 接口是派生类的 public 接口的一部分。

pure virtual(纯虚函数)

A virtual function declared in the class header using =0 at the end of the function's parameter list. A pure virtual is one that need not be (but may be) defined by the class. A class with a pure virtual is an abstract class. If a derived class does not define its own version of an inherited pure virtual, then the derived class is abstract as well.

类的头文件中在函数形参表末尾 =0 声明的虚函数。类不必(但可以)定义纯虚函数。带纯虚函数的类为抽象类。如果派生类没有定义所继承的纯虚函数的自身版本,则派生类也是抽象类。

refactoring(重构)

Redesigning programs to collect related parts into a single abstraction, replacing the original code by uses of the new abstraction. In OO programs, refactoring frequently happens when redesigning the classes in an inheritance hierarchy. Refactoring often occurs in response to a change in requirements. In general, classes are refactored to move data or function members to the highest common point in the hierarchy to avoid code duplication.

重新设计程序将相关部分集合到一个抽象中,用新抽象的使用代替原来的代码。在面向对象编程中,重新设计继承层次中的类时经常发生重构。响应需求的改变通常需要进行重构。一般而言,对类进行重构时,需要将数据或函数成员移到继承层次的最高公共点以避免代码重复。

sliced(切掉的)

Term used to describe what happens when an object of derived type is used to initialize or assign an object of the base type. The derived portion of the object is "sliced down," leaving only the base portion, which is assigned to the base.

描述用派生类型对象对基类类型对象进行初始化或赋值时情况的术语。对象的派生部分被“切掉”,只留下基类部分,赋给基类对象。

static type(静态类型)

Compile-time type. Static type of an object is the same as its dynamic type. The dynamic type of an object to which a reference or pointer refers may differ from the static type of the reference or pointer.

编译时类型。对象的静态类型与动态类型相同。引用或指针所引用的对象的动态类型可以不同于引用或指针的静态类型。

virtual function(虚函数)

A member function that defines type-specific behavior. Calls to a virtual made through a reference or pointer are resolved at run time, based on the type of the object to which the reference or pointer is bound.

定义类型明确的行为的成员函数。通过引用或指针进行的虚函数调用,在运行时基于引用或指针定制对象而确定。

Team LiB
Previous Section Next Section