First, the access range of the private, public, and protected access labels.
PRIVATE: It can only be accessed by 1. functions in this class, 2. Other functions. Cannot be accessed by any other user, nor can the object of this class be accessed.
Protected: it can be accessed by 1. functions in this class, 2. Sub-class functions, and 3. Its membership functions. But cannot be accessed by objects of this class.
Public: it can be accessed by 1. functions in this class, 2. Sub-class functions, 3. Its friends functions, or 4. objects in this class. Note: There are three types of functions: normal non-member functions set as friends, member functions of other classes set as friends, and all member functions in the friends class.
Second, the method property changes after the class is inherited.Private attributes cannot be inherited.
Using private inheritance, the protected and public attributes of the parent class are changed to private in the subclass;
Using Protected inheritance, the protected and public attributes of the parent class are changed to protected in the subclass;
Use public inheritance. The protected and public attributes in the parent class are not changed. See the following: public: protected: Private:
Public inherits from public protected and is unavailable.
Protected inherits protected. Protected is unavailable.
Private inheritance Private cannot use protected inheritance or private inheritance to reduce access permissions.