Inheritance: – It a technique to create a new class from existing class.

Existing class = base class, supper class, parent class etc.

New class = derived class, sub class, child class etc.

Syntax to create new class –

                Class New_Class_Name:Access_Specifier Existing_Class_Name
                                {
                                _ _ _ _ _;
                                _ _ _ _ _;
                                };

Ex: –

                Class child:public parent
                                {
                                _ _ _ _ _;
                                _ _ _ _ _;
                                };

Note: – A child class has its own properties as well as public or protected properties of its parent class. This term is also called as reusability.

Reusability: – Always a child class utilizes the reusability concept (Because it can access the property of its parent class) reusability concept is helpful to avoid the data redundancies so it improves the performance the program.

Base Class Access Mode

Derived Class Access Mode

Private Derivation

Public Derivation

Protected Derivation

Public Private Public Protected
Private Not Inherited Not Inherited Not Inherited
Protected Private Protected Protected
Advertisements