stupid question

Hi All,

In a base class if I have a function in protected scope, I get that in private in the derived class.

what if i want it in protected scope of the derived class too?


~Cheers!
navderm
You can:

1) inherit publicly (which changes what's in the derived class' public interface) OR
2) use the "using" clause to lift in into the protected section.

Example of latter:

1
2
3
4
5
6
7
8
9
struct Base {
    protected:
        void foo();
};

struct Derived : protected Base {
    protected:
        using Base::foo;
};

If you have a protected member, it will still be a protected member in the derived class if you inherit publicly
Topic archived. No new replies allowed.