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

            亚洲欧美伊人久久综合一区二区 | 国产成人精品久久一区二区三区| 亚洲国产精品久久久天堂| 99久久综合国产精品免费| 久久综合久久自在自线精品自| 97精品久久天干天天天按摩| 久久精品国产欧美日韩| 久久国产亚洲精品| 久久亚洲精品中文字幕三区| 无码任你躁久久久久久久| 成人久久精品一区二区三区| 青青草原综合久久大伊人导航| 久久国产欧美日韩精品| 免费一级欧美大片久久网| 久久青青草原综合伊人| 精品国产99久久久久久麻豆| a级毛片无码兔费真人久久| 久久人妻少妇嫩草AV蜜桃| 久久A级毛片免费观看| 欧美亚洲国产精品久久久久| 婷婷综合久久狠狠色99h| 伊人久久综合成人网| 亚洲欧美精品一区久久中文字幕 | 久久国产成人亚洲精品影院| 日本人妻丰满熟妇久久久久久| 久久国产福利免费| 精品国产91久久久久久久a| 91精品国产9l久久久久| 久久99精品久久久久子伦| 欧洲成人午夜精品无码区久久 | 精品久久久久久无码中文野结衣| 国产V综合V亚洲欧美久久| 亚洲精品乱码久久久久久按摩| 欧美性猛交xxxx免费看久久久| 国产精品九九久久免费视频| 久久国产精品久久国产精品| 色综合久久无码五十路人妻| 无码超乳爆乳中文字幕久久| 久久国产精品无码HDAV| 国产精品国色综合久久| 91精品国产91久久久久久青草|