inheritance in program and advantage.

Inheritance in program

        Inheritance:

inheritance is a technique of program that is used to reuse an existing class to build a new class. inheritance mostly used to create or developed a new class form old existing class. it is most important feature of program in c++.
the new class inherits all the feature and behavior of the existing class in program. the old and existing class reused to create in a new class . the new class that is create from a existing class called super class, base class and parent class. 
the super class, base class and parent class inherits the feature of an existing class is know as a subclass, derived class and child class.

class hierarchy is the inheritance relationship between the classes of a program.
        
        inheritance is the one of the most important feature of object oriented programming .
the basic properties of inheritance is that each subclass or child class shares common properties with the class from which it is derived.
the sub class inherits all capabilities of the super class and can add its own capabilities.
     
     example of inheritance.
lets a class named vehicle is already created. the subclasses of this class may share similar properties such as wheels  and  motor etc.
additionally, a subclass may have its own particular characteristics. 
for example, a train may have seats for people but another ship subclass may have space to carry goods. 
 lets take another example of Animals  can be divided into sub class such as mammal. insect  and  reptiles.
 the above example shows that the  Animals is the parent class and mammal, insects  and  reptiles
are three sub classes. the sub class indicate that the subclasses are derived from the parent class  animals. 

   Advantages of  inheritance .

  • Reusability.
    Inheritance allows the developer to reuse existing code in many situations. A class can be created once and it can be reused again and again to create many subclass.

  • Save Time and Effort 
Inheritance saves a lot of time and effort to write the same classes again and again . The reusability of existing classes allows the program to work only on new class.

  • Increases program Structure and Reliability.
A super class is already compiled and tested properly. this class can be used in new application without compiling it again. the use of existing class increase program reliability.


inheritance example