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

            久久久久久久久无码精品亚洲日韩| 国产精品嫩草影院久久| 久久午夜无码鲁丝片秋霞| 久久久久久免费视频| 亚洲AV无码久久| 91久久精品无码一区二区毛片| 久久av免费天堂小草播放| 亚洲精品成人网久久久久久| 亚洲国产欧美国产综合久久| 伊人热人久久中文字幕| 国产免费久久精品99re丫y| 99久久免费国产精精品| 色婷婷狠狠久久综合五月| 国产精品久久波多野结衣| 少妇熟女久久综合网色欲| 日韩精品国产自在久久现线拍| 久久久久久精品免费看SSS| 久久91综合国产91久久精品| 久久热这里只有精品在线观看| 精品久久久久久中文字幕| 精品久久久中文字幕人妻| 精品99久久aaa一级毛片| 亚洲国产精品无码久久久蜜芽| 久久五月精品中文字幕| 久久精品国产福利国产秒| 少妇内射兰兰久久| 久久99久国产麻精品66| 伊人伊成久久人综合网777| 久久se精品一区精品二区国产| 国产91色综合久久免费分享| 久久精品亚洲AV久久久无码| 四虎影视久久久免费| 久久午夜福利电影| 日本欧美国产精品第一页久久| 国产99久久久国产精品~~牛| 久久777国产线看观看精品| 麻豆成人久久精品二区三区免费| 久久人人爽人人爽人人av东京热| 久久毛片一区二区| 久久亚洲精品无码VA大香大香| 久久久一本精品99久久精品88|