- A private member is accessible only to member of the class in which they are declared. They are not visible in derived class or from outside of the class where they are declared except friend functions/ classes.
- A private member of the base class cab be accessed in the derived class through the public member functions of the base class.
- A protected member is accessible to members of its own and any of the members in a derived class or the friend of base or friend of derived class.
- The members that might be used in derived class should be declared as protected rather than private.
- A public member is accessible to members of its own class, member of derived class and even outside the class.
Sunday, November 13, 2011
Inheritance: protected Access Specifier
Bibek Subedi is a computer engineering gratuate and founder of Programing Techniques. He loves researching in the field of Machine learning, data mining and Algorithms. He is a part time blogger, a bathroom singer (:D) and an employee of a software company. You can follow him in Twitter and find him in Facebook or mail him