• <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 閱讀(277) 評論(0)  編輯 收藏 引用 所屬分類: Notes

            久久久久无码精品国产| 亚洲国产精品无码久久SM| 久久免费精品视频| 国产亚州精品女人久久久久久| 麻豆久久| 色欲久久久天天天综合网 | 久久久无码精品午夜| 性做久久久久久久久| 久久久久无码精品国产不卡| 精品综合久久久久久88小说| 久久亚洲熟女cc98cm| 91精品国产91久久| 日韩中文久久| 91精品国产乱码久久久久久| 亚洲欧美日韩精品久久亚洲区 | 999久久久国产精品| 久久91精品国产91久| 国产A级毛片久久久精品毛片| 久久久久久精品免费免费自慰| 99久久精品国产麻豆| 久久精品国产久精国产果冻传媒 | 久久综合九色综合精品| 午夜精品久久久久久毛片| 久久综合久久鬼色| 国产伊人久久| 青青青国产精品国产精品久久久久| 久久夜色精品国产噜噜亚洲a| 国产福利电影一区二区三区久久老子无码午夜伦不 | 久久久久一级精品亚洲国产成人综合AV区 | 久久久久99精品成人片欧美| 亚洲七七久久精品中文国产 | 久久精品亚洲男人的天堂| 久久久久综合网久久| 99久久免费国产精品热| 久久精品午夜一区二区福利| 亚洲国产精品无码久久SM| 色偷偷88888欧美精品久久久| 久久久久免费精品国产| 欧美成a人片免费看久久| 久久99精品国产麻豆蜜芽| 久久综合九色综合久99|