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

            99久久人人爽亚洲精品美女| 久久久无码人妻精品无码| 久久精品国产99久久香蕉| 久久人人爽人人澡人人高潮AV | 亚洲精品无码久久毛片| 亚洲精品无码久久久影院相关影片| 久久久久亚洲AV片无码下载蜜桃| 久久中文娱乐网| 伊人伊成久久人综合网777| 久久久久亚洲AV无码网站| 久久精品国产欧美日韩| 人妻精品久久久久中文字幕一冢本| 国产69精品久久久久9999| 精品久久久无码21p发布| 久久久久久A亚洲欧洲AV冫| 久久国产乱子伦免费精品| 精品久久人人爽天天玩人人妻| 亚洲综合婷婷久久| 激情伊人五月天久久综合| 性做久久久久久久久浪潮| 国产成人99久久亚洲综合精品| 色欲av伊人久久大香线蕉影院| 蜜桃麻豆www久久国产精品| 青青国产成人久久91网| 久久人爽人人爽人人片AV| 99精品国产99久久久久久97| 合区精品久久久中文字幕一区| 久久艹国产| 伊人情人综合成人久久网小说| 久久高潮一级毛片免费| 国产精品伦理久久久久久| 很黄很污的网站久久mimi色| 91久久精品国产成人久久| 国产精品99久久不卡| 九九久久精品国产| 久久久精品日本一区二区三区| 久久精品夜色噜噜亚洲A∨| 久久一区二区三区免费| 久久综合亚洲色HEZYO社区| 欧美va久久久噜噜噜久久| 久久国产高潮流白浆免费观看|