• <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>

            EverSpring working shop

            To pursue creative ideas based on nature.

            統計

            留言簿(1)

            他山之石

            閱讀排行榜

            評論排行榜

            Constructor usgae in the base type and the derived type

            • When the constructor of the derived class is defined, we should consider and ensure how the base type is initialized:
              • If the base type has default constructor, the constructor in the derived class may ignore the initialization for the memebers in base type.
              • If the base type have no default constructor, the constructor in the derived class should explict initialize the base type in the initialization list via the user defined base type constructor.

             

            // testing.cpp : Defines the entry point for the console application.
            //

            #include 
            "stdafx.h"
            #include 
            "stdio.h"
            #include 
            <iostream>

            using namespace std;

            class BASE
            {
            public:
                BASE(
            int x):i(x){};
                BASE()
            {};
            private:
                
            int i;
            }
            ;

            class derived: public BASE
            {
            public:
                derived(
            int x):BASE(x)
                
            {
                    j 
            = x;
                    
            //this->BASE::BASE(x);
                }
            ;
            private:
                
            int j;
            }
            ;

            class grandson: public derived
            {
            public:
                grandson(
            int x, int y):derived(y),j(x){}//use the defined constructor for derived because no defual contructor defined
            private:
                
            int j;
            }
            ;

            int _tmain(int argc, _TCHAR* argv[])
            {
                
            int a = 0;
                cout 
            <<"debugging";

                BASE base_obj(
            5);
                BASE base_obj_2(
            7);

                BASE 
            *ptr = &base_obj;
                BASE 
            *ptr_b = ptr;

                
            int sizeofobj = (int)sizeof(base_obj);

                ptr 
            = (BASE*)((char*)ptr + sizeofobj);

                derived der_obj(
            6);
                derived der_obj_2(
            9);

                
            //der_obj_2 = base_obj; //there is no acceptable conversion from BASE -> Derived

                base_obj_2 
            = der_obj;

                
            return 0;
            }

            posted on 2007-10-21 23:29 everspring79 閱讀(278) 評論(0)  編輯 收藏 引用 所屬分類: Notes

            女人香蕉久久**毛片精品| 国产精品美女久久久久 | 久久se精品一区精品二区| 久久99精品国产一区二区三区| 精品无码久久久久久尤物| 欧美伊香蕉久久综合类网站| 国内精品久久久久久麻豆| 亚洲αv久久久噜噜噜噜噜| 99久久精品费精品国产| 色欲久久久天天天综合网| 精品无码久久久久久尤物| 国产 亚洲 欧美 另类 久久| 精品久久久无码人妻中文字幕| 91精品国产91热久久久久福利| 亚洲AⅤ优女AV综合久久久| 国产精品一区二区久久| 亚洲国产成人久久精品99 | 国产成人精品久久免费动漫| 久久久亚洲AV波多野结衣| 999久久久免费精品国产| 亚洲伊人久久综合影院| 一级做a爱片久久毛片| 日韩精品久久无码人妻中文字幕 | 色狠狠久久综合网| 久久久久久噜噜精品免费直播| 麻豆AV一区二区三区久久 | 久久男人中文字幕资源站| 999久久久免费国产精品播放| 久久精品国产99国产精品导航| AA级片免费看视频久久| 久久精品蜜芽亚洲国产AV| 久久久久亚洲精品天堂| 香蕉久久AⅤ一区二区三区| 狠狠色综合网站久久久久久久| 99久久99久久| 久久99热国产这有精品| 久久精品水蜜桃av综合天堂| 久久亚洲欧美国产精品| 久久久久久久97| av无码久久久久不卡免费网站| 久久大香香蕉国产|