• <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久久国产宗和精品1上映 | 亚洲欧美一级久久精品| 国产精品久久久久久久人人看| 国产成人精品久久| 国产人久久人人人人爽| 欧美国产精品久久高清| 久久91亚洲人成电影网站| 青青热久久国产久精品| 久久综合丝袜日本网| 精品国产乱码久久久久久1区2区| 嫩草影院久久99| 久久中文字幕视频、最近更新| 99久久国产宗和精品1上映| 热99re久久国超精品首页| 久久SE精品一区二区| 久久成人国产精品免费软件| 国产成人久久精品区一区二区| 久久亚洲私人国产精品| 一本色道久久88精品综合| 国产精品伦理久久久久久| 国内精品久久久久久中文字幕| 99久久精品国产一区二区蜜芽 | 人妻精品久久久久中文字幕| 狼狼综合久久久久综合网| 久久亚洲国产成人影院| 一本色道久久综合| 久久se这里只有精品| 国产精品成人99久久久久 | 亚洲国产精品成人久久| 亚洲国产精品无码久久久秋霞2| 亚洲天堂久久精品| 婷婷久久综合九色综合98| 成人国内精品久久久久影院| 伊人久久大香线蕉av不变影院| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区| 国产精品一区二区久久精品涩爱| 久久久久一本毛久久久| 久久久久国产视频电影| 亚洲欧美精品一区久久中文字幕 | 久久精品嫩草影院| 青青国产成人久久91网|