Q-38: Write a C++ program to demonstrate the concept of multi-level inheritance.
        

Using - C++


// Contributed by - Debojyoti Chakraborty ( GC College, Silchar - @ Department of Computer Science ) #include<iostream> using namespace std; class A { public: int x; void getData_A() { cout<<"Enter the value of X = "; cin>> x; } }; // Class-C derived from Class-A class B : public A { public: int y; void getData_B() { cout<<"Enter the value of Y = "; cin>> y; } }; // Class-C derived from Class-B class C : public B { public: int z; void getData_C() { cout<<"Enter the value of Z = "; cin>> z; } void showProduct() { cout<<"\nThe product of X, Y & Z is : "<< x * y * z; } }; int main() { C obj; obj.getData_A(); obj.getData_B(); obj.getData_C(); obj.showProduct(); return 0; }

OUTPUT

Enter the value of X = 3
Enter the value of Y = 4
Enter the value of Z = 5

The product of X, Y & Z is : 60