Posts

Image
  Modes of Inheritance Public mode: Mode of inheritance public means public member of base class becomes public in derived class and protected member of base class becomes protected in derived class.   Public member of base class will become public member in derived class protected member of base class will become protected member in derived class  Protected mode:    Mode of Inheritance protected means  both public member and protected members of the base class will become protected in derived class. Both public and protected member of Base class will become protected in derived class Private mode:  Mode of Inheritance Private means  both public member and protected members of the base class will become Private in derived class. Both public and protected member of the Base class will become Private member in derived class Types of Inheritance: There are following types of Inheritance: 1) Single Inheritance:   Single inheritance allowed to inherit from only one class. That means there
Image
Inheritance  What is the purpose of Inheritance? Purpose of inheritance is that it increases code reusability of program. Rule of Inheritance Only public and protected  member can be inherited. Private member of Base class  never be inherited. Base Class : It is the class which derived in derived class. Derived Class : It is the class derived from Base class that means whatever public and protected member of base class can be inherited in derived class based on mode of inheritance. So, need not be declare in derived class again if those members are already declared in base class.  Syntax: class  derived_classname : access_mode base_classname {   //body of subclass }; Here, access mode can be public , private or protected. Modes of Inheritance Public mode: Mode of inheritance public means public member of base class becomes public in derived class and protected member of base class becomes protected in derived class.   Public member of base class will become public member in der