编程语言

img lynnboy

1.8 - [intro.object] - 【总则.对象】

发表于2004/10/29 13:50:00  854人阅读

请不要转载本文;请不要以任何形式重新出版,发布本文;请在下载本文 24 小时内将其删除;禁止将本文用于商业目的。

1 General [intro]

1.8 The C++ object model [intro.object]

 

1 总则 【总则】

1.8 C++ 对象模型 【总则.对象】

 

The constructs in a C++ program create, destroy, refer to, access, and manipulate objects. An object is a region of storage. [Note: A function is not an object, regardless of whether or not it occupies storage in the way that objects do. ] An object is created by definition (3.1), by a new-expression (5.3.4) or by the implementation (12.2) when needed. The properties of an object are determined when the object is created. An object can have a name (clause 3). An object has a storage duration (3.7) which influences its lifetime (3.8). An object has a type (3.9). The term object type refers to the type which the object is created. Some objects are polymorphic (10.3); the implementation generates information associated with each such object that makes it possible to determine that object's type during program execution. For other objects, the interpretation of the values found therein is determined by the type of the expressions (clause 5) used to access them.

 

在 C++ 的程序构造中创建,销毁,引用,访问并操作对象。对象是一块存储区域。【:无论函数占据存储的方式是否与对象相同,函数都不是对象。】对象按需通过定义(3.1),new 表达式(5.3.4)或由实现创建。当对象创建后,对象的特性就被确定。对象可以有名字(章节3)。对象具有存储类型(3.7),并影响它的生存期(3.8)。对象具有类型(3.9)。术语对象类型指对象创建时 所使用的类型。一些对象是多态的(10.3);为了在程序运行时能够决定多态的对象的类型,实现为每个这种对象生成相关的信息。对于其他对象,以访问这些对象的表达式(章节5)的类型来决定如何解释它们所存放的值。

 

Objects can contain other objects, called sub-objects. A sub-object can be a member sub-object (9.2), a base class sub-object (clause 10), or an array element. An object that is not a sub-object of any other object is called a complete object.

 

对象可以包含被称为子对象的其他对象。子对象可以是成员子对象(9.2),基类子对象(章节10),或数组元素。不是任何其他对象的子对象的对象 被称为完整对象

 

For every object x, there is some object called the complete object of x, determined as follows:
  • If x is a complete object, then x is the complete object of x.
  • Otherwise, the complete object of x is the complete object of the (unique) object that contains x.

 

对每个对象 x,存在被称为 x 的完整对象的对象,判定如下:
  • 如果 x 是完整对象,则 x 的完整对象是 x。
  • 否则,x 的完整对象是包含 x 的(唯一)完整对象。

 

If a complete object, a data member (9.2), or an array element is of class type, its type is considered the most derived class, to distinguish it from the class type of any base class subobject; an object of a most derived class type is called a most derived object.

 

如果完整对象,数据成员或数组元素具有类类型,则其类型被看作最终派生类,以之与此类的任何基类子对象的类型区别;一个最终派生类类型的对象被称为最终派生对象

 

Unless it is a bit-field (9.6), a most derived object shall have a non-zero size and shall occupy one or more bytes of storage. Base class sub-objects may have zero size. An object of POD4) type (3.9) shall occupy contiguous bytes of storage.

 

除非作为位域(9.6),否则最终派生对象总是具有非零大小并总占用一个以上字节的存储。基类子对象可以具有零大小。POD4) 类型(3.9)的对象总是占用连续的字节存储。

 

[Note: C++ provides a variety of built-in types and several ways of composing new types from existing types (3.9). ]

 

:C++ 有许多内建类型,并提供几种利用已有类型组合出新类型的方法(3.9)。】

 

4) The acronym POD stands for “plain old data.”

 

4) POD 是“老式朴素数据”的首字母缩写。

 

PREV [intro.memory] | NEXT [intro.execution] 上一页 【总则.内存】 | 下一页 【总则.执行】
阅读全文
0 0

相关文章推荐

img
取 消
img