C++ language

A Simple Program On multilevel Inheritance
Previous Home Next
#include<iostream.h>
Class A
{
int a,b;
public :
void getdata()
{
cout<<"\n Enter the value of a and b";
cin>>a>>b;
}
void putdata()
{
cout<<"\n The value of a is :"<<a<<"and b :"<<b;
}
};
class B : public A     //class  is publicly derived from A
{
int c,d;
public :
void intdata()
{
cout<<"\n Enter the value of c and d :";
cin>>c>>d;
}
void outdata()
{
cout<<"\n The value of c ;"<<c<<"and d :"<<d;
}
};
class C: public B
{
int e,f;
public :
void input()
{
cout<<"\n Enter the value of e and f";
cin>>e>>f;
}
void output()
{
cout<<"\nthe value  of e is" <<e<<"and f is"<<f;
}
};
void main()
{
C obj;
obj.getdata();       //member function of class A
obj.indata();       //member function of class B
obj.input();        //member function of class C
obj.putdata();      //member function of class A
obj.outdata();      //member function of class B 
obj.output();       //member function of class C
}

output:

Enter the value of a and b
4
5
Enter the value of c and d
6
7
Enter the value of e and f
9
3
The value of a is 4 and b is 5
The value of c is 6 and d is 7
The value of e is 9 and f is 3
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: