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

            狠狠色丁香久久综合五月| 久久免费小视频| 2020国产成人久久精品| 久久免费视频1| 国产69精品久久久久9999APGF | 久久笫一福利免费导航| 久久久久久国产精品美女| 久久精品午夜一区二区福利| 东京热TOKYO综合久久精品| 久久国产精品视频| 久久夜色精品国产欧美乱| 999久久久国产精品| 一本久久a久久精品亚洲| 亚洲一区二区三区日本久久九| 日本五月天婷久久网站| 久久精品男人影院| 久久久久国产精品嫩草影院| 99久久精品免费| 久久精品国产亚洲一区二区| 久久久www免费人成精品| 国内精品欧美久久精品| 精品久久久噜噜噜久久久| 伊人久久久AV老熟妇色| 狠狠久久综合伊人不卡| 久久九九青青国产精品| 久久精品无码一区二区无码| 亚洲AV无码久久| 免费一级做a爰片久久毛片潮| 久久亚洲综合色一区二区三区| 人妻少妇久久中文字幕| 欧美伊人久久大香线蕉综合| 久久久国产一区二区三区| 伊人久久免费视频| 久久精品国产秦先生| 91久久福利国产成人精品| 99久久99久久精品国产| 久久精品国产影库免费看| 99久久免费只有精品国产| 色综合久久中文综合网| 狠狠人妻久久久久久综合| 国产精品免费久久|