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

            波多野结衣中文字幕久久| 久久精品国产国产精品四凭| 日本久久久久亚洲中字幕| 97久久精品无码一区二区天美| www.久久热.com| 久久91精品国产91| 久久精品国产秦先生| 久久人人爽人人爽人人爽| 久久99久久99小草精品免视看| 亚洲伊人久久综合影院| 久久精品毛片免费观看| 伊人久久大香线蕉成人| 免费观看久久精彩视频| 2020久久精品亚洲热综合一本| 一本久久久久久久| 久久精品aⅴ无码中文字字幕不卡 久久精品成人欧美大片 | 久久夜色精品国产| 精品久久8x国产免费观看| 久久人人爽人人人人爽AV | 久久精品成人影院| 久久综合久久综合久久| 久久综合狠狠综合久久| 久久精品国产免费观看三人同眠| 国内精品久久久久久中文字幕 | 久久亚洲私人国产精品vA| 无码精品久久一区二区三区 | 日产精品久久久久久久| 久久免费看黄a级毛片| 亚洲美日韩Av中文字幕无码久久久妻妇 | 日韩精品久久无码人妻中文字幕| 欧美精品丝袜久久久中文字幕| 色成年激情久久综合| 国产欧美久久久精品| 久久精品嫩草影院| 精品久久久久久国产免费了| 国产成人AV综合久久| 久久久久免费视频| 日本亚洲色大成网站WWW久久 | 无码人妻久久一区二区三区蜜桃 | 久久无码人妻一区二区三区午夜 | 国产高清国内精品福利99久久|