• <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>
            asm, c, c++ are my all
            -- Core In Computer
            posts - 139,  comments - 123,  trackbacks - 0

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


            C++對(duì)象模型(1)


            作者: Jerry Cat
            時(shí)間: 2006/04/20
            鏈接: http://www.shnenglu.com/jerysun0818/archive/2006/04/20/5969.html

            Chapter 0 : Preface
            =-=-=-=-=-=-=-=-=-=
            I must also say that the general pattern of virtual function implementation across all current compilation systems is to use a class-specific virtual table of a fixed size that is constructed prior to program execution.

            Chapter 1: Object Lessons
            =-=-=-=-=-=-=-=-=-=-=-=-=
            1.1 The C++ Object Model
            -------------------------
            (1). class Point
            {
            public:
            ?? Point( float xval );
            ?? virtual ~Point();
            ?? float x() const;
            ?? static int PointCount();

            protected:
            ?? virtual ostream& print( ostream &os ) const;
            ?? float _x;
            ?? static int _point_count;
            };

            Stroustrup's original (and still prevailing) C++ Object Model is derived from the simple object model by optimizing for space and access time. Nonstatic data members are allocated directly within each class object. Static data members are stored outside the individual class object. Static and nonstatic function members are also hoisted outside the class object. Virtual functions are supported in two steps:

            ? 1). A table of pointers to virtual functions is generated for each class (this is called the virtual table).

            ? 2). A single pointer to the associated virtual table is inserted within each class object (traditionally, this has been called the vptr). The setting, resetting, and not setting of the vptr is handled automatically through code generated within each class constructor, destructor, and copy assignment operator (this is discussed in Chapter 5). The type_info object associated with each class in support of runtime type identification (RTTI) is also addressed within the virtual table, usually within the table's first slot.

            (2). 加入繼承后
            C++ supports both single inheritance:

            class Library_materials { ... };
            class Book : public Library_materials { ... };
            class Rental_book : public Book { ... };
            and multiple inheritance:

            // original pre-Standard iostream implementation
            class iostream:
            ?? public istream,
            ?? public ostream { ... };
            Moreover, the inheritance may be specified as virtual (that is, shared):

            class istream : virtual public ios { ... };
            class ostream : virtual public ios { ... };

            In the case of virtual inheritance, only a single occurrence of the base class is maintained (called a subobject) regardless of how many times the class is derived from within the inheritance chain. iostream, for example, contains only a single instance of the virtual ios base class.

            How might a derived class internally model its base class instance? In a simple base class object model, each base class might be assigned a slot within the derived class object. Each slot holds the address of the base class subobject. The primary drawback to this scheme is the space and access-time overhead of the indirection. A benefit is that the size of the class object is unaffected by changes in the size of its associated base classes.

            Alternatively, one can imagine a base table model. Here, a base class table is generated for which each slot contains the address of an associated base class, much as the virtual table holds the address of each virtual function. Each class object contains a bptr initialized to address its base class table. The primary drawback to this strategy, of course, is both the space and access-time overhead of the indirection. One benefit is a uniform representation of inheritance within each class object. Each class object would contain a base table pointer at some fixed location regardless of the size or number of its base classes. A second benefit would be the ability to grow, shrink, or otherwise modify the base class table without changing the size of the class objects themselves.

            The original inheritance model supported by C++ forgoes all indirection; the data members of the base class subobject are directly stored within the derived class object. This offers the most compact and most efficient access of the base class members. The drawback, of course, is that any change to the base class members, such as adding, removing, or changing a member's type, requires that all code using objects of the base class or any class derived from it be recompiled.

            posted on 2006-04-20 18:13 Jerry Cat 閱讀(574) 評(píng)論(0)  編輯 收藏 引用

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



            <2006年4月>
            2627282930311
            2345678
            9101112131415
            16171819202122
            23242526272829
            30123456

            常用鏈接

            留言簿(7)

            隨筆檔案

            最新隨筆

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            亚洲第一永久AV网站久久精品男人的天堂AV | 99久久免费只有精品国产| 日韩av无码久久精品免费| 久久综合鬼色88久久精品综合自在自线噜噜| 国产亚洲美女精品久久久久狼| 波多野结衣AV无码久久一区| 久久久久久久综合狠狠综合| 久久精品国产99国产电影网 | 91久久国产视频| 人妻无码精品久久亚瑟影视| 久久精品国产亚洲麻豆| 精品综合久久久久久88小说| 亚洲国产精品18久久久久久| 国产亚洲成人久久| 国产99久久久国产精品~~牛| 四虎国产精品成人免费久久| 日韩美女18网站久久精品| 色噜噜狠狠先锋影音久久| 久久99亚洲网美利坚合众国| 久久久久国产精品嫩草影院| 无码人妻久久一区二区三区蜜桃| 精品久久人妻av中文字幕| 色偷偷88888欧美精品久久久 | 久久国产劲爆AV内射—百度| 国产福利电影一区二区三区久久老子无码午夜伦不 | 久久久精品国产免大香伊| 777午夜精品久久av蜜臀| 久久久久久国产a免费观看不卡| 久久综合成人网| 国产亚洲美女精品久久久2020| 一级a性色生活片久久无| 久久午夜伦鲁片免费无码| 久久久噜噜噜www成人网| 久久99精品国产麻豆宅宅| 国产成人香蕉久久久久| 久久久久亚洲AV成人网人人网站 | 香蕉aa三级久久毛片| 久久久久亚洲av无码专区| 亚洲国产精品无码久久青草| 久久精品国产清高在天天线| 久久婷婷色香五月综合激情|