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

            久久久久久精品久久久久| 久久久亚洲欧洲日产国码是AV| 欧美日韩精品久久久免费观看| 久久婷婷国产综合精品| 国产精品嫩草影院久久| 77777亚洲午夜久久多人| 久久精品国产WWW456C0M| 国内精品久久久久影院优| 中文字幕久久精品 | 日本人妻丰满熟妇久久久久久| 日本久久久久亚洲中字幕| 国产激情久久久久影院| 波多野结衣久久| 久久精品无码一区二区三区日韩| 久久久久久国产精品无码下载| 国产成人无码精品久久久免费| 伊人色综合久久天天人手人婷| 久久久久久久久久久免费精品| 久久亚洲精精品中文字幕| 中文字幕精品无码久久久久久3D日动漫| 成人久久精品一区二区三区| 国产精品女同久久久久电影院 | 久久久久无码国产精品不卡| 久久久精品2019免费观看| 久久婷婷五月综合97色| 成人综合久久精品色婷婷| 亚洲综合婷婷久久| 99久久国产综合精品成人影院| 一本色道久久HEZYO无码| 伊人久久大香线蕉综合5g| 久久久久国产亚洲AV麻豆| 国产精品美女久久久免费| 青青热久久综合网伊人| 久久精品18| 国产呻吟久久久久久久92| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久99国产精品尤物| 亚洲av成人无码久久精品| 久久精品人人做人人爽97| 国产激情久久久久久熟女老人| 国内精品综合久久久40p|