I correctly understand that when we have private inheritance, the level of private members of the derived class is divided, as it were, into private and into private, private. That is, with private inheritance, the base class field goes into the category of private fields of a derivative, if it was in public from the base class - we can access such a field in the derived class through the public derivative method. The base class field goes into the category of private private derivative, if it was private in the base class - we can refer to this field as follows: public methods of the derivative -> private methods from inherited from the base -> (at the private private level) variable inherited from the base (which was there private)?

Accordingly, if you create a hierarchy of N classes with one private inheritance, then you can have N sublevels of the private level in the descendant))

#include <iostream> using namespace std; class A { public: A(){ch = 'A'; a = 100;} void showA(){ cout << ch << endl; } int a; private: void showC(){ cout << "C" << endl; } char ch; }; class B : A { public: void showB(){ showA(); } void showZ(){ cout << a << endl; } // void showCh(){ // cout << ch << emdl; // } private: }; int main() { B obj; obj.showZ(); obj.showB(); // output: A //obj.showCh(); // error return 0; } 
  • one
    Maybe here and you can build some kind of clever multi-level terminology, but I don’t see the point. So far, all lacked only three levels: private, protected and public, and how they are transformed into each other during private, protected and public inheritance. - AnT
  • Voobshe about what he did not understand - AR Hovsepyan
  • But the derived class does not have access to the private field of the base class - AR Hovsepyan

0