Public,protected,private Access Summary in C + +
First: The access scope of the Private,public,protected method. (Under public inheritance)
Private: can only be accessed by a function in the class, its friend function, and cannot be accessed by any other object of the class.
Protected: can be accessed by functions in the class, functions of subclasses, and their friend functions, but cannot be accessed by objects of that class
Public: can be accessed by functions in the class, by functions of subclasses, by their friend functions, or by objects of that class
Note: The friend function consists of two kinds: global function set as friend, set as member function in friend class
Second: Post-Inheritance Method property changes for classes:
With private inheritance, all methods of the parent class become private in subclasses;
With protected inheritance, the protected and public methods of the parent class change to Protected,private method in the subclass;
Using public inheritance, the method attribute in the parent class does not change;
Protected inheritance and private inheritance can reduce access rights
C + + Inheritance