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

            久久91精品国产91久久麻豆| 伊人久久精品无码二区麻豆| 国内精品久久九九国产精品| 亚洲天堂久久精品| 久久久久亚洲精品中文字幕| 一97日本道伊人久久综合影院| 国产成人精品综合久久久久 | 国产精品成人久久久久三级午夜电影| 久久线看观看精品香蕉国产| 久久精品国产一区二区三区| 一本一道久久综合狠狠老| 久久国产精品-久久精品| 久久乐国产精品亚洲综合| 亚洲综合熟女久久久30p| 久久综合丁香激情久久| 精品一二三区久久aaa片| 国产精品成人99久久久久 | 久久午夜无码鲁丝片午夜精品| 亚洲愉拍99热成人精品热久久| 热久久国产精品| 午夜精品久久久久久中宇| 久久久久国产日韩精品网站 | 久久精品二区| 久久99国产精品久久久| 天天爽天天狠久久久综合麻豆| 久久久久国产一区二区| 久久精品国产亚洲一区二区| 婷婷久久久亚洲欧洲日产国码AV | 99久久这里只有精品| 亚洲欧美成人综合久久久| 日本精品久久久久影院日本| 中文字幕久久欲求不满| 国产成人精品久久二区二区| 久久久一本精品99久久精品88| 亚洲AV伊人久久青青草原| 久久精品国产福利国产琪琪| 丁香久久婷婷国产午夜视频| 99精品伊人久久久大香线蕉| 久久精品男人影院| 日本精品久久久久中文字幕| 成人妇女免费播放久久久|