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

            国产精品久久久久影视不卡| 亚洲国产精品人久久| 久久久久久亚洲精品不卡| 久久精品成人| 中文字幕热久久久久久久| 久久99国产乱子伦精品免费| 久久精品国产只有精品2020| 亚洲AⅤ优女AV综合久久久| 无码国内精品久久人妻蜜桃| 色综合久久中文综合网| 精品国产乱码久久久久久呢| AA级片免费看视频久久| 无码国内精品久久人妻| 日产久久强奸免费的看| 久久国产精品一区二区| 久久久久亚洲av成人网人人软件 | 久久国产高清字幕中文| 日韩中文久久| 国内精品久久久久久不卡影院| 99久久精品国产一区二区| 欧美伊人久久大香线蕉综合69 | 欧美精品丝袜久久久中文字幕| 欧美丰满熟妇BBB久久久| 亚洲欧美一级久久精品| 久久精品二区| 99久久国产亚洲高清观看2024| 久久亚洲精品人成综合网| 久久亚洲欧洲国产综合| 国产成人无码精品久久久免费| 亚洲va久久久噜噜噜久久| 热99RE久久精品这里都是精品免费 | 波多野结衣AV无码久久一区| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久国语露脸国产精品电影| 日韩精品国产自在久久现线拍| 91精品国产综合久久精品| 草草久久久无码国产专区| 2021久久精品国产99国产精品| 国产精品久久久久久影院| 久久经典免费视频| 久久夜色精品国产噜噜亚洲a|