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

            性色欲网站人妻丰满中文久久不卡| 久久―日本道色综合久久| 久久久精品国产sm调教网站 | 无码国内精品久久综合88| 亚洲中文字幕无码一久久区| 99久久中文字幕| 午夜精品久久久久9999高清| 一本一本久久aa综合精品| 精品少妇人妻av无码久久| 久久久精品久久久久影院| 99久久精品国产一区二区| 无码人妻精品一区二区三区久久| 久久精品午夜一区二区福利| 国内精品久久久久久久coent| 国产一区二区久久久| 国产精品久久久久影视不卡| 青青草原综合久久大伊人导航 | 亚洲va久久久噜噜噜久久天堂| 久久精品视频网| 91精品国产色综合久久| 九九热久久免费视频| 久久久久亚洲AV无码专区体验| 久久无码一区二区三区少妇| 国内精品久久久久久不卡影院 | 精品999久久久久久中文字幕| 久久99精品久久久久久噜噜 | 国产精品久久久久久久午夜片 | 国产精品无码久久久久久| 久久综合鬼色88久久精品综合自在自线噜噜| 国产成人无码精品久久久性色| 久久国产影院| 香蕉久久夜色精品国产尤物| a级成人毛片久久| 久久久久99精品成人片直播| 亚洲日韩中文无码久久| 久久国产欧美日韩精品免费| 久久精品二区| 久久久久97国产精华液好用吗| 精品国产福利久久久| 久久精品国产亚洲一区二区| 久久r热这里有精品视频|