分享
 
 
 

C++研究笔记(6)存储模型和对象模型

王朝c/c++·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

C++ 存储模型是 C++ 程序实现的物理基础,C++ 对象模型是 C++ 语义实现的逻辑基础。C++ 标准指出:

1.7 The C++ memory model [intro.memory]

The fundamental storage unit in the C++ memory model is the byte. A byte is at least large enough to contain any member of the basic execution character set and is composed of a contiguous sequence of bits, the number of which is implementation-defined. The least significant bit is called the low-order bit; the most significant bit is called the high-order bit. The memory available to a C++ program consists of one or more sequences of contiguous bytes. Every byte has a unique address.

C++ 存储模型的基本存储单元是字节。一个字节应该至少具有足够表示运行时基本字符集的任意成员的大小,并且由实现定义个数的连续位构成。最低有效位称为低序位,最高有效位称为高序位。对于 C++ 程序有效的存储由一个或多个字节连续序列组成。每个字节有唯一的地址。

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

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:

对每个对象 x,存在被称为 x 的完整对象的对象,判定如下:

If x is a complete object, then x is the complete object of x.

如果 x 是完整对象,则 x 的完整对象是 x。

Otherwise, the complete object of x is the complete object of the (unique) object that contains 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 PODi) type (3.9) shall occupy contiguous bytes of storage.

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

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

POD 是“老式普通数据”的首字母缩写。

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

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有