Multilevel Inheritance in c++ Example



Multilevel Inheritance in c++ Example


  GNU nano 2.9.1                                                        test.cpp                                                        Modified  

/********************************************************************************************************
******************************Designed and Developed by V2Geeks******************************************
********************************************************************************************************/

 // Example of  multilevel Inheritance (A->B->C)
 #include<iostream.h>
 #include<conio.h>
 class A                             // base class
 {
public:
        void display()
        {
        cout<<"Hello from A \n";
}
};
class B : public A                  // now class  B is child of class  A
 {
// now B have display method of it's parent class A
 };
 class C : public B                  // now class B is child of class  C
 {
  // now C have display method of it's parent class B
 };

 void main()
 {
 C       obj  ;          //object of child class C
 clrscr();
 obj.display();
         getch();
 }

Reactions: