简体   繁体   中英

How can I introduce base class member to derived class definition, but only one overload?

With 'using declarations' I can introduce a base class member into definition of my class:

class Base {
    public:
    void baseMemberFn();
    /* ... */
};

class Derived : private Base {
    public:
    using Base::baseMemberFn;
};

However, in my case, I want to only 'use' one specific overload of the member from the base class. Is there a syntax to do so?

There's no syntax for that.

Make a new member function with the same name, that forwards the call to the parent:

void baseMemberFn() {Base::baseMemberFn();}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM