- The mechanism of deriving new class from an existing class is called inheritance. The main advantage of Inheritance is it supports reusability of code.
- The derived class inherits all the properties of the base class. It is a power packed class, as it can add additional attributes and methods and thus enhance its functionality. The various types of Inheritance are Single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance and hybrid inheritance
- When a derived class inherits only from one base class, it is known as single inheritance When a derived class inherits from multiple base classes itis known as multiple inheritance
- When a class is derived from a class which is a derived class itself – then this is referred to as multilevel inheritance. The transitive nature of inheritance is reflected by this form of inheritance.
- When more than one derived classes are created from a single base class, it is known as Hierarchical inheritance.
- When there is a combination of more than one type of inheritance, it is known as hybrid inheritance. In multiple inheritance, the base classes are constructed in the order in which theyorder.Theappear in the declaration of the derived class.
- A sub-class can derive itself publicly, privately or protectedly.
- The private member of a class cannot be inherited.
- In publicly derived class,the public members of the base class remain public and protected members of base class remain protected in derived class.
- In privately derived class, the public and the protected members of the base class become private in derived class
- When class is derived in protected mode,the public and protected members of base class become protected in derived class.
- Constructors and destructors of the base class are not inherited but during the creation of an object for derived class the constructors of base class will automatically be invoked.
- The destructors are invoked in reverse order.The destructors of the derived classes are invoked first and then the base class.
- The size of derived class object-size of all base class data members + size of all data members in derived class overriding of the members are resolved by using Scope resolution operator(::). this pointer is used to refer to the current objects members