青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

asm, c, c++ are my all
-- Core In Computer
posts - 139,  comments - 123,  trackbacks - 0

********************************************\
|????歡迎轉(zhuǎn)載, 但請(qǐng)保留作者姓名和原文鏈接, 祝您進(jìn)步并共勉!???? |
\********************************************/


C++對(duì)象模型(11) - 3.3 Access of a Data Member
作者: Jerry Cat
時(shí)間: 2006/11/15
鏈接:?
http://m.shnenglu.com/jerysun0818/archive/2006/11/15/15193.html


3.3 Access of a Data Member

1. Static Data Members:

Static data members are literally lifted out of their class, as we saw in Section 1.1 and treated as if each were declared as a global variable (but with visibility limited to the scope of the class).但其可視范圍只在類內(nèi).

Each member's access permission and class association is maintained without incurring any space or runtime overhead either in the individual class objects or in the static data member itself.

A single instance of each class static data member is stored within the data segment of the program. Each reference to the static member is internally translated to be a direct reference of that single extern instance. For example,

// origin.chunkSize == 250;
Point3d::chunkSize == 250;

// pt->chunkSize == 250;
Point3d::chunkSize == 250;

What if the access of the static data member is through a function call or some other form of expression? For example, if we write

foobar().chunkSize == 250;

what happens to the invocation of foobar()? In the pre-Standard language, one didn't know what would happen: It was left unspecified in the ARM whether foobar() had to be evaluated. In cfront, for example, it was simply discarded. Standard C++ explicitly requires that foobar() be evaluated, although no use is made of its result. A probable translation looks as follows:

// foobar().chunkSize == 250;

// evaluate expression, discarding result
(void) foobar();
Point3d::chunkSize == 250;
Taking the address of a static data member yields an ordinary pointer of its data type, not a pointer to class member, since the static member is not contained within a class object. For example,

&Point3d::chunkSize;
yields an actual memory address of type
const int*

2. Nonstatic Data Members:

Nonstatic data members are stored directly within each class object and cannot be accessed except through an explicit or implicit class object. An implicit class object is present whenever the programmer directly accesses a nonstatic data member within a member function. For example, in the following code:

Point3d
Point3d::translate( const Point3d &pt ) {
?? x += pt.x;
?? y += pt.y;
?? z += pt.z;
}
the seemingly direct access of x, y, and z is actually carried out through an implicit class object represented by the this pointer. Internally, the function is augmented as follows:

? // internal augmentation of member function
? Point3d
? Point3d::translate( Point3d *const this, const Point3d &pt ) {
???? this->x += pt.x;
???? this->y += pt.y;
???? this->z += pt.z;
? }

Access of a nonstatic data member requires the addition of the beginning address of the class object with the offset location of the data member. For example, given

origin._y = 0.0;
the address of

&origin._y;
is equivalent to the addition of

&origin + ( &Point3d::_y - 1 );//注意減1
(Notice the peculiar "subtract by one" expression applied to the pointer-to-data-member offset value. Offset values yielded by the pointer-to-data-member syntax are always bumped up by one. Doing this permits the compilation system to distinguish between a pointer to data member that is addressing the first member of a class and a pointer to data member that is addressing no member(減一用以讓編譯系統(tǒng)區(qū)分兩類數(shù)據(jù)成員指針: 一種是尋址第一個(gè)數(shù)據(jù)成員; 另一種是不對(duì)數(shù)據(jù)成員尋址). Pointers to data members are discussed in more detail in Section 3.6.)

編譯時(shí)確定, 效率不減.The offset of each nonstatic data member is known at compile time, even if the member belongs to a base class subobject derived through a single or multiple inheritance chain. Access of a nonstatic data member, therefore, is equivalent in performance to that of a C struct member or the member of a nonderived class.

Virtual inheritance introduces an additional level of indirection in the access of its members through a base class subobject. Thus

Point3d *pt3d;
pt3d->_x = 0.0;
performs equivalently if _x is a member of a struct, class, single inheritance hierarchy, or multiple inheritance hierarchy, but it performs somewhat slower if it is a member of a virtual base class. In the next sections, I examine the effect of inheritance on member layout. Before I turn to that, however, recall the question at the beginning of this section: When, if ever, is the access of the coordinate data members, such as

origin.x = 0.0;
pt->x = 0.0; //當(dāng)面臨虛基類時(shí)&pt->x是不確定的, 而&origin.x則是在編譯時(shí)確定的
ever significantly different when accessed through the object origin or the pointer pt? The answer is the access is significantly different when the Point3d class is a derived class containing a virtual base class within its inheritance hierarchy and the member being accessed, such as x, is an inherited member of that virtual base class. In this case, we cannot say with any certainty which class type pt addresses (and therefore we cannot know at compile time the actual offset location of the member), so the resolution of the access must be delayed until runtime through an additional indirection. This is not the case with the object origin. Its type is that of a Point3d class, and the offset location of even inherited virtual base class members are fixed at compile time. An aggressive compiler can therefore resolve the access of x through origin statically.

posted on 2006-11-15 23:37 Jerry Cat 閱讀(1292) 評(píng)論(0)  編輯 收藏 引用

只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理



<2006年11月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

常用鏈接

留言簿(7)

隨筆檔案

最新隨筆

搜索

  •  

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            av72成人在线| 蜜臀av性久久久久蜜臀aⅴ四虎 | 一区二区视频欧美| 久久精品国产欧美激情| 欧美一区二区性| 伊人成人在线视频| 亚洲第一色在线| 欧美日韩亚洲一区| 欧美一区午夜精品| 亚洲另类春色国产| 日韩一级黄色大片| 国产欧美一区二区三区在线看蜜臀| 欧美一区在线看| 久久午夜视频| 亚洲影院免费观看| 欧美在线视频一区二区| 亚洲精品久久嫩草网站秘色| 欧美一区二区三区精品| 久久精品最新地址| 亚洲调教视频在线观看| 欧美在线视频一区二区| 亚洲免费观看在线观看| 亚洲综合第一页| 亚洲精品韩国| 性欧美长视频| 一区二区三区欧美| 欧美在线资源| 亚洲午夜精品网| 久久一二三四| 午夜一级在线看亚洲| 免费日韩一区二区| 欧美在线播放| 欧美日韩综合不卡| 亚洲成色777777在线观看影院| 欧美无砖砖区免费| 欧美91大片| 国产区二精品视| 亚洲精品网址在线观看| 尤物99国产成人精品视频| 一区二区三区四区五区精品| 亚洲激情国产| 欧美在线你懂的| 亚洲自拍三区| 欧美三级电影网| 亚洲人人精品| 亚洲高清一区二| 欧美在线关看| 久久国产精品72免费观看| 欧美电影美腿模特1979在线看| 久久精品青青大伊人av| 欧美日韩一区在线| 亚洲人成小说网站色在线| 亚洲国产精品ⅴa在线观看| 欧美怡红院视频| 欧美一区久久| 国产九区一区在线| 亚洲一级高清| 午夜视频精品| 国产精品每日更新在线播放网址| 亚洲三级网站| 日韩一级视频免费观看在线| 欧美高清在线| 91久久中文| 夜夜嗨av一区二区三区网站四季av| 免费欧美日韩国产三级电影| 欧美国产欧美亚洲国产日韩mv天天看完整 | 久久av一区二区三区漫画| 欧美三级电影大全| a4yy欧美一区二区三区| 亚洲色图自拍| 国产精品二区在线| 亚洲伊人第一页| 久久精品免视看| 狠狠色狠狠色综合| 美女国内精品自产拍在线播放| 久久网站热最新地址| 激情视频一区| 欧美丰满高潮xxxx喷水动漫| 欧美大尺度在线观看| 日韩午夜中文字幕| 国产精品va在线| 欧美影院成人| 亚洲国产成人精品女人久久久| 亚洲国产精品一区制服丝袜 | 男男成人高潮片免费网站| 亚洲国产精品一区| 亚洲免费电影在线观看| 欧美特黄a级高清免费大片a级| 中日韩美女免费视频网址在线观看| 欧美一级欧美一级在线播放| 国产精品久久久久毛片软件| 久久精品国产免费看久久精品| 久热精品在线视频| 亚洲国产小视频在线观看| 欧美三级乱码| 久久精品女人| 夜夜狂射影院欧美极品| 欧美一站二站| 亚洲区一区二| 国产午夜精品视频| 一区二区久久| 欧美va天堂| 一区二区激情视频| 韩曰欧美视频免费观看| 欧美精品在线播放| 午夜久久黄色| 亚洲精品一区二区三区福利| 午夜精品视频在线观看一区二区| 黄色精品网站| 国产精品videosex极品| 麻豆国产精品一区二区三区| 亚洲在线观看视频网站| 91久久久国产精品| 久久综合中文| 欧美一区亚洲一区| 中文一区在线| 亚洲国产精品成人一区二区| 国产精品永久在线| 欧美日韩一区国产| 欧美成人免费全部| 久久久一区二区三区| 亚洲欧美成人一区二区三区| 日韩亚洲视频在线| 亚洲成在人线av| 美女视频一区免费观看| 欧美一区观看| 午夜精品www| 亚洲欧美日本精品| 在线亚洲美日韩| 一本一本久久| 99www免费人成精品| 亚洲黄色免费网站| 精品成人乱色一区二区| 国产专区精品视频| 国产午夜精品在线| 国产午夜精品一区二区三区欧美 | 女生裸体视频一区二区三区| 久久精品国语| 久久狠狠亚洲综合| 欧美专区第一页| 欧美伊人精品成人久久综合97| 亚洲一区图片| 午夜精品剧场| 欧美一级片在线播放| 欧美一区二区日韩| 欧美一区二区视频免费观看| 午夜精品久久久久久久男人的天堂| 亚洲天堂免费观看| 亚洲欧美一区二区三区极速播放| 亚洲一区精品视频| 亚洲欧美日韩综合| 欧美在线免费观看视频| 久久精品主播| 欧美第一黄色网| 欧美日韩一区二区三区免费看| 欧美日韩影院| 国产免费亚洲高清| 黄色成人在线| 亚洲六月丁香色婷婷综合久久| 99在线精品观看| 香蕉国产精品偷在线观看不卡| 欧美一区二区国产| 久久人人爽国产| 亚洲国产99| 中文在线资源观看网站视频免费不卡| 亚洲女同精品视频| 噜噜爱69成人精品| 欧美日本在线视频| 国产女人精品视频| 18成人免费观看视频| 99re热这里只有精品视频| 一本一本大道香蕉久在线精品| 亚洲一区二区三区乱码aⅴ蜜桃女| 在线一区二区三区四区| 欧美在线视频一区二区三区| 黑人中文字幕一区二区三区| 精品电影一区| 夜夜爽www精品| 久久久久久9999| 亚洲国产精品一区二区尤物区| 99在线热播精品免费99热| 久久er精品视频| 欧美日韩色综合| 国产综合婷婷| 亚洲在线观看| 亚洲国产合集| 久久精品亚洲一区二区三区浴池| 欧美精品www| 一区二区亚洲精品| 欧美一级在线视频| 91久久精品国产91久久性色tv| 亚欧成人在线| 国产精品电影观看| 99成人在线| 欧美成人精品激情在线观看 | 久久国产免费| 一本色道久久88亚洲综合88| 裸体女人亚洲精品一区| 国内精品久久久久影院色| 在线中文字幕一区|