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

            他山之石

            閱讀排行榜

            評論排行榜

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

            久久成人精品视频| 国产精品一区二区久久精品| 久久久久久免费一区二区三区| 国产精品久久久福利| 亚洲国产成人久久精品动漫| 国内精品久久久久久久涩爱| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 中文字幕亚洲综合久久菠萝蜜| 久久人人爽人人爽人人爽| 久久一日本道色综合久久| av无码久久久久不卡免费网站| 久久青青草原精品影院| 中文精品99久久国产| 久久免费线看线看| 人妻丰满AV无码久久不卡| 久久午夜综合久久| 久久夜色精品国产噜噜麻豆| 久久高清一级毛片| 久久精品国产亚洲欧美| 国产成人综合久久精品红| 国产一区二区三区久久精品| 久久久亚洲AV波多野结衣| 国产精品免费久久久久久久久| 色欲av伊人久久大香线蕉影院| 色偷偷91久久综合噜噜噜噜| 国产成人精品久久一区二区三区| 久久精品国产99国产精品亚洲| 精品国产青草久久久久福利| 久久精品国产亚洲AV电影| 亚洲AV无码久久| 亚洲欧美精品一区久久中文字幕| 国产精品一区二区久久精品无码| 色综合久久无码中文字幕| 99蜜桃臀久久久欧美精品网站| 香蕉久久永久视频| 伊人久久大香线蕉综合网站| 久久精品亚洲精品国产欧美| 久久久久亚洲?V成人无码| 香蕉aa三级久久毛片| 人妻无码αv中文字幕久久琪琪布 人妻无码精品久久亚瑟影视 | 四虎国产精品免费久久|