Basic Program for Multilevel Inheritance
In this, we are going to see a basic program for Multilevel Inheritance in C++ Programming Language. 


The Code given below can be used in TURBO C++ Compilers: -


#include<iostream.h>
#include<conio.h>

class A
{
    public:
    void show()
    {
        cout << "Hello from class A printed from object of class C";
    }
};

class B : public A
{
};

class C : public B
{
};

void main()
{
    clrscr();
    C obj;
    obj.show();
    getch();
}

//...........Coded by Sahil Shaikh


The Code given below can be used in gcc/g++ Compilers: -

#include <iostream>
using namespace std;

class A
{
    public:
    void show()
    {
        cout << "Hello from class A printed from object of class C";
    }
};

class B : public A
{
};

class C : public B
{
};

int main()
{
    C obj;
    obj.show();
    return 0;
}

//...........Coded by Sahil Shaikh


#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post