Class Access Specifiers
Data hiding is one of the important features of Object Oriented Programming which allows preventing the functions of a program to access directly the internal representation of a class type. The access restriction to the class members is specified by public, private, and protected sections within the class body. The keywords public, private, and protected are called access specifiers. The default access specifier for members is private.
in child classes which are called derived classes
A public member is accessible from anywhere outside the class but within a program.You can set and get the value of public data members even without using any member function.
A private member cannot be accessed from outside the class. Only the class member functions can access private members.By default all the members of a class would be private.
A protected member is very similar to a private member but it Provides one additional benefit that they can be accessed (inherited classes).