2. Inheritance
class derived-class-name : visibility-mode base-class-name{
// ...
}
• three keywords: public, private, or protected
• determines how elements of the base class are inherited by the
derived class
3. Making a Private Member Inheritable
• Private member of a base class cannot be inherited
• Not available to derived class directly
• We can change private to public that will make accessible to all
other function.(There is no Data Hiding)
• C++ introduce third visibility modifier i.e., protected(limited
purpose in inheritance).
Protected
– accessible by the other member function within its class and
immediately derived class.
4. Protected
public mode private mode
1. accessible by derived class 1. accessible by derived class of
Of member function member function
2.Ready for further inheritance 2.not available for further inheritance