Write a c++ program
:
a) to illustrate multilevel inheritance.
#include<iostream.h>
#include<conio.h>
class student
{
protected : int
rollno; public : void get_num();
void put_num();
};
void student::get_num()
{
cout<<"\nEnter the roll number:\t"; cin>>rollno;
}
void student::put_num()
{
cout<<"Rollnumber:
"<<rollno;
}
class test:public
student
{
protected : float sub1,sub2; public:
void get_marks()
{
cout<<"\nEnter the sub1 marks: "; cin>>sub1;
cout<<"\nEnter the sub2 marks: "; cin>>sub2;
}
void put_marks()
{
cout<<"\nSub1="<<sub1;
cout<<"\nSub2="<<sub2;
}
};
class result : public
test
{
float total;
public:
void display()
{
total=sub1+sub2; put_num(); put_marks();
cout<<"\nTotal=
"<<total;
}
};
int main()
{
clrscr();
result r;
r.get_num();
r.get_marks();
r.display();
getch();
return 0;
}
*****************************OUTPUT******************************
Enter the roll number:
11111
Enter the sub1 marks:
67
Enter the sub2 marks:
56
Rollnumber: 11111
Sub1=67
Sub2=56
Total= 123