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

            久久―日本道色综合久久| 日韩精品久久久肉伦网站| 国产精品狼人久久久久影院| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 久久久久99精品成人片欧美| 人妻久久久一区二区三区| 久久久噜噜噜久久中文福利| 午夜不卡888久久| 怡红院日本一道日本久久 | 国产99久久九九精品无码| 久久夜色撩人精品国产小说| 亚洲精品乱码久久久久久中文字幕| 久久精品国产网红主播| 色婷婷综合久久久久中文字幕| 无码国内精品久久人妻| 久久久久亚洲av成人无码电影| 久久久无码精品亚洲日韩蜜臀浪潮| 99久久无色码中文字幕 | 久久婷婷五月综合97色一本一本| 国产亚州精品女人久久久久久 | 99久久无码一区人妻a黑| 日韩美女18网站久久精品| 国产精品99久久久久久人| 狠狠色丁香久久婷婷综合图片| 色综合久久中文综合网| 久久成人国产精品| 伊人色综合久久天天人手人婷| 久久无码精品一区二区三区| 国产精品视频久久久| 中文字幕热久久久久久久| 久久天天躁狠狠躁夜夜2020一| 久久久久久国产a免费观看不卡| 久久精品国产91久久综合麻豆自制| 亚洲午夜无码久久久久| 久久久久久久久66精品片| 精品一久久香蕉国产线看播放 | 久久婷婷综合中文字幕| 久久超乳爆乳中文字幕| 粉嫩小泬无遮挡久久久久久| 久久国产精品99精品国产| 91精品国产乱码久久久久久 |