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

            他山之石

            閱讀排行榜

            評論排行榜

            Call Super Function in the Override function of the derived class

            The derived class overrides the function in the base class. However, in some cases, we need to reuse the function of the base class in the overrided function. For C++, the scope operator is used to force a call to use a particular version of a overrided function.
            Below is the example code, this code also contains the usage of the private inheritance.


            #include "stdafx.h"

            #include 
            <iostream>
            #include 
            "stdio.h"
            #include 
            <string>
            using namespace std;

            class base 
            {
            public:
                
            void basename()
                
            {
                    cout 
            << "this is base name\n";
                }

            protected:
                
            int i;
                
            void base2ndname()
                
            {
                    cout
            <<"this is base private name\n";
                }

            }
            ;

            class private_derived:private base  //private derivation, access control updates for the user of derivated class 
            {
            public:
                
            void basename() //override the base function
                {
                    cout 
            << "this is my derived name\n";
                    
            //basename();  // This will cause the endless loop
                    this->base::basename();
                }
            ;
                
            int use_base()
                
            {
                    
            this->base::basename();  // use the scope operator to use the base class function
                    this->base::base2ndname();
                    basename();
                    
            return i;
                }

            }
            ;

            int _tmain(int argc, _TCHAR* argv[])
            {
                base base_obj;
                private_derived derive_obj;

                cout 
            << derive_obj.use_base();

            }

            posted on 2007-10-21 18:07 everspring79 閱讀(360) 評論(0)  編輯 收藏 引用 所屬分類: Notes

            狠狠人妻久久久久久综合| 精品国产乱码久久久久久呢| 伊人久久综合成人网| 色99久久久久高潮综合影院 | 久久毛片免费看一区二区三区| 欧美日韩精品久久免费| 三级片免费观看久久| 亚洲精品97久久中文字幕无码| 久久久久亚洲AV成人网人人网站| 国产精品成人无码久久久久久| 精品国产91久久久久久久| 激情伊人五月天久久综合| 2021久久精品国产99国产精品| www性久久久com| 丰满少妇人妻久久久久久4| 精品久久久久久久久久久久久久久| 日本道色综合久久影院| 国产精品欧美久久久久无广告| 久久99精品国产麻豆婷婷| 思思久久好好热精品国产| 亚洲香蕉网久久综合影视| 一本久久免费视频| 久久精品国产清高在天天线| 久久国产美女免费观看精品 | 午夜精品久久久久久毛片| 亚洲国产另类久久久精品黑人| 久久久久亚洲Av无码专| 国产精品无码久久久久| 久久久这里只有精品加勒比| 久久综合亚洲欧美成人| 99热都是精品久久久久久| 亚洲精品乱码久久久久久不卡| 精品国产乱码久久久久久呢| 亚洲伊人久久大香线蕉苏妲己| 亚洲va久久久久| 国产精品美女久久久| 亚洲精品97久久中文字幕无码| 亚洲中文字幕无码久久2017| 久久精品免费大片国产大片| 久久久久久国产精品无码下载| 香蕉久久夜色精品国产小说|