文档介绍:毕业论文5000字英文文献翻译(c++)
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
装
┊
┊
┊
┊
┊
订
┊
┊
┊
┊
┊
线hen we use library facilities such as IO, we must include the associated headers. Similarly, for our own classes, we must make the definitions associated with the class available to the compiler. We do so in much the same way. Typically, we put the class definition into a file. Any program that wants to use our class must include that file.
Conventionally, class types are stored in a file with a name that, like the name of a program source file, has two parts: a file name and a file suffix. Usually the file
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
装
┊
┊
┊
┊
┊
订
┊
┊
┊
┊
┊
线
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
┊
安徽工业大学 毕业设计(论文)说明书
共 13 页 第 3 页
a class is implemented, but programmersthat use the class need not know about these details. Instead, programmers who use a type need to know only the type's interface; they can think abstractly about what the type does rather than concretely about how the type works.
Encapsulation is a term that describes the technique of combining lower-level elements to forma new, higher-level entity. A function is one form of encapsulation: The detailed actions performedby the function are encapsulated in the larger entity that is the function itself. Encapsulated elements hide the details of their implementationwe may call a function but have no access to the statements that it executes. In the same way, a class is an encapsulated entity: It represents an aggregation of several members, and most (well-designed) class types hide the members that implement the type.
If we think about the library vector type, it is an example of both data abstraction and encapsulation. It is abstract in that to use it, we think about its interfaceabout the operations that it can perform. It is encapsulated because we have no access to the details of