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

            久久久久人妻一区精品性色av| Xx性欧美肥妇精品久久久久久 | 久久婷婷国产麻豆91天堂| 久久99国产亚洲高清观看首页 | 久久综合亚洲色HEZYO国产| 亚洲精品白浆高清久久久久久 | 久久这里只有精品视频99| 狠狠色噜噜色狠狠狠综合久久 | 精品人妻伦九区久久AAA片69 | 麻豆av久久av盛宴av| 精品午夜久久福利大片| 久久亚洲国产精品成人AV秋霞| 国产精品一区二区久久精品| 久久久久久久久久久| 99久久精品免费看国产一区二区三区 | 2021最新久久久视精品爱| 久久精品国产91久久麻豆自制 | 无码伊人66久久大杳蕉网站谷歌| 久久久久九九精品影院| 91精品国产综合久久精品| 天堂久久天堂AV色综合| 精产国品久久一二三产区区别 | 久久久久亚洲av无码专区| 日韩欧美亚洲综合久久| 无码任你躁久久久久久老妇| 国产精品综合久久第一页| 99久久夜色精品国产网站| 韩国三级大全久久网站| 久久精品视频网| 91精品国产综合久久香蕉 | 97久久婷婷五月综合色d啪蜜芽| 亚洲а∨天堂久久精品| 亚洲精品国产自在久久| 午夜福利91久久福利| 色99久久久久高潮综合影院| 久久婷婷五月综合色99啪ak| 久久丝袜精品中文字幕| 亚洲综合久久久| 少妇久久久久久久久久| 国产亚洲欧美精品久久久| 久久综合九色综合97_久久久|