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

            統(tǒng)計

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

            精品综合久久久久久888蜜芽| 久久有码中文字幕| 色综合久久中文字幕无码| 亚洲精品乱码久久久久久| 色8久久人人97超碰香蕉987| 久久亚洲国产中v天仙www| 亚洲国产精品综合久久网络| 亚洲国产精品无码久久SM| 日本三级久久网| 久久久久人妻精品一区二区三区| 国产精品久久波多野结衣| 亚洲乱码日产精品a级毛片久久| 亚洲AV日韩AV永久无码久久| 久久精品国产只有精品66| 午夜精品久久久久久中宇| 青青热久久国产久精品 | 国内精品久久久久影院网站| 无码八A片人妻少妇久久| 天天爽天天爽天天片a久久网| 国内精品伊人久久久影院| 亚洲综合精品香蕉久久网97| 久久久久亚洲精品无码蜜桃| 97精品伊人久久大香线蕉| 国产精品成人无码久久久久久| 伊人久久无码中文字幕| 香蕉久久永久视频| 亚洲精品乱码久久久久久蜜桃| 情人伊人久久综合亚洲| av无码久久久久久不卡网站| 久久av无码专区亚洲av桃花岛| 亚洲va久久久久| 精品久久久久久无码不卡| 午夜精品久久久久久影视riav| 精品水蜜桃久久久久久久| 国产精品欧美久久久久无广告| 国产精品无码久久久久久| 精品免费久久久久久久| 天天爽天天狠久久久综合麻豆| 亚洲国产精品高清久久久| 午夜欧美精品久久久久久久| 国内精品久久久久久99蜜桃|