INHERITANCE IN C++

Maha

INHERITANCE WITH C++

      Inheritance is one of the most important features of Object Oriented Programming.

      In object-oriented programming, inhertance enables new class and its objects to take on the properties of the existing classes. 

      A class that is used as the basis for creating a new class is called a superclass or base class.

     A class that inherits from a superclass is called a subclass or derived class. 

      It is a process of creating new classes called derived classes,from the existing or base classes.
     
    The class to be inherited is called base class or parent class and the class which inherits the other class is called derived class or child class.

The main advantage of inheritance is

 • It represents real world relationships well 
 • It provides reusability of code
 • It supports transitivity

Types of inheritance

        There are different types of inheritance are.,
                   1.  Single Inheritance
                   2. Multiple Inheritance
                   3. Hierarchical Inheritance
                   4. Multilevel Inheritance
                   5. Hybrid Inheritance

1. Single Inheritance

     When a derived class inherits only from one base class,it is known as single Inheritance.

2. Multiple Inheritance

      When a derived class inherits from multiple base classes it is known as multiple Inheritance


3. Hierarchical Inheritance

      When more than one derived classes are created from a single base class, it is known as Hierarchical Inheritance.

4. Multilevel Inheritance

      The transitive nature of inheritance is reflected by this form of inheritance. When a class is derived from a class which is a derived class then it is refferred to as multilevel Inheritance.


5. Hybrid Inheritance

       When there is a combination of more than one type of inheritance to design a program. it is known as hybrid Inheritance. 




Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send