How do you make a private member in the base class become a public member in the base class?

Posted by jasonline on Stack Overflow See other posts from Stack Overflow or by jasonline
Published on 2010-03-28T15:10:28Z Indexed on 2010/03/28 15:13 UTC
Read the original article Hit count: 230

Filed under:
|

Consider the following code:


class Base
{
    void f() { }
};

class Derived: public Base
{
public:

};

What can you change in the derived class, such that you can perform the following:


Derived d;
d.f();

If the member is declared as public in the base class, adding a using declaration for Base::f in the derived class public section would've fix the problem. But if it is declared as private in the base class, this doesn't seem to work.

© Stack Overflow or respective owner

Related posts about c++

Related posts about inheritance