1. For a single class, the meanings of the three range delimiters are as follows:
Public Member ProgramCan be accessed anywhere. Classes that implement information hiding restrict their public members to member functions. Such functions define operations that can be used by General programs to manipulate objects of this type.
Private Members can only be accessed by Friends of member functions and classes. Classes that implement information hiding declare their data members as private
The protected member (protected member) is like a public member to the derived class of the derived class, and acts like a private member to other programs.
In short, for a single class member function, whether the member variable is public, protected or private, it can be accessed, but for the Class Object (that is, the class instance) for example, you can only access public variables and member functions, but not those of the protected and private types.
2. For class inheritance, there are also three types of inheritance: public, protected, and private. The three inheritance definitions are as follows (assume that A is a base class and B is a derived class ):
Public inheritance: the members of the public type in Class A are still public in Class B. The members of the protected type in Class A are protected in Class B, and the members of the private type in Class A are invisible in Class B.
Protected inheritance: members of the public type in Class A are converted to the protected type in Class B, and members of the protected type in Class A are still of the protected type in Class B, private Members in Class A are not visible in Class B.
Private inheritance: members of the public and protected types in Class A are converted to the private type in Class B, and members of the private type in Class A are invisible in Class B.