1

Regardless of whether it is public, private or protected inheritance, the private members of the base class are not accessible to the functions exclusive to the derived class.

This is my conclusion. Is it correct?

Related notes would be appreciated.

Also, in private inheritance, the public members of the base class would be private in the derived class but the new functions of the derived class can still access them directly. Correct?

Grant
  • 143
  • 1
  • 1
  • 6

1 Answers1

2

Why not test it?

class Base {
private: 
    int a;
};

// Private inheritance.
class A : private Base {
public:
    A() {
        a = 0;
    }
};

This gives me:

error: 'int Base::a' is private

The type of inheritance does not matter when it comes to the ability for a class to access it's base-classes private variables.