Cover up inheritance names

Source: Internet
Author: User
///////////////////////////////////////////////////////////////////////////////////  FileName    :   effect_item33.h//  Version     :   0.10//  Author      :   Ryan Han//  Date        :   2013/07/26 16:50:14//  Comment     :  /////////////////////////////////////////////////////////////////////////////////#ifndef EFFECT_ITEM33_H#define    EFFECT_ITEM33_Hclass base{public:    virtual void mf1() = 0;    virtual void mf1(int);    virtual void mf2();    void mf3();    void mf3(double);private:    int x;};class derive : public base {public:    using base::mf1;    void mf1();    void mf4();private:    int y;};#endif
///////////////////////////////////////////////////////////////////////////////////  FileName    :   effect_item33.cpp//  Version     :   0.10//  Author      :   Ryan Han//  Date        :   2013/07/26 16:50:14//  Comment     :  /////////////////////////////////////////////////////////////////////////////////#include "effect_item33.h"#include <iostream>using namespace std;void base::mf1() {    cout << "base::mf1() was called." << endl;}void base::mf1(int) {    cout << "base::mf1(int) was called." << endl;}void base::mf2() {    cout << "base::mf2() was called." << endl;}void base::mf3() {    cout << "base::mf3() was called." << endl;}void base::mf3(double) {    cout << "base::mf3(double) was called." << endl;}void derive::mf1() {    cout << "derive::mf1() was called." << endl;}void derive::mf4() {    cout << "derive::mf4() was called." << endl;}
///////////////////////////////////////////////////////////////////////////////////  FileName    :   effect_item33_client.cpp//  Version     :   0.10//  Author      :   Ryan Han//  Date        :   2013/07/26 16:50:14//  Comment     :  //    Output        ://    $ ./a///////////////////////////////////////////////////////////////////////////////#include "effect_item33.h"#include <iostream>using namespace std;int main() {    derive d;    d.mf1();    d.mf1(3);    return 0;}

The member functions in the inheritance class overwrite the functions of the same name in the base class. Functions in the base class are invisible no matter whether virutal is not virtual or the parameters are the same.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.