Public MemberProgramThe class that implements Information Hiding can be accessed anywhere and its public members are restricted to member functions. This function defines the private member that can be used by General programs to manipulate objects of this type. the data member can only be declared as private by the class with Information Hiding implemented by the member functions and the class's friends.
Protected member protected member performs private on the derived class just like a public member for other programs.
PRIVATE: The members declared in the Section (data members or member functions) can only be accessed by the member functions and Friends of the class.
In the protected section of the class, the declared members (no matter data members or member functions) can only be accessed by the member functions of the class, the member functions and Friends of the friends and sub-classes.
In the public: Section of the class, the declared members (whether data members or member functions) can be accessed by anyone.
Public, private, or proteced, which controls how variable members and member functions are accessed within and outside the class. In-class access refers to access using class member functions, while in-class access refers to access using objects or pointers to objects.
When a class member is defined as public, it can be accessed outside the class, including its derived class.
When a member is defined as private, it can only be accessed within the class and cannot be accessed by its derived class.
When a member is defined as proteced, it can only be accessed within the class, but can be accessed by its derived class.
When no access specifier is specified for a member, the default value is private.
When defining a derived class, the access specifier can also appear before the base class, which controls the access methods of the variable members and member functions of the base class in the derived class. When the access description is public, it is called public inheritance. Similarly, when the question specifier is protected, it is called protection inheritance, and when the question specifier is private, it is called private inheritance.
In public inheritance, the Public Member of the base class becomes the Public Member of the derived class, and the protected member of the base class becomes the protected member of the derived class.
When the inheritance is protected, the public and protected members of the base class become the protected members of the derived class.
When private inheritance is performed, the public and protected members of the base class are both private members of the derived class.