Write a C++ program to demonstrate Multi Level inheritance.
Inheritance types
2. Multi Level inheritance :-
Code :-
/**********program to implement inheritance (Multi Level inheritance)*****/
#include<iostream.h>
#include<conio.h>
class student
{
protected:
int rno;
char sname[10];
};
class course:public student
{
protected:
char cname [10];
int fee;
};
class admission:public course
{
int fp,fr;
public :
void get()
{
cout<<"Enter The Roll No :- ";
cin>>rno;
cout<<"Enter The Student Name :- ";
cin>>sname;
cout<<"Enter Course Name :- ";
cin>>cname;
cout<<"Enter Total Fees :- ";
cin>>fee;
cout<<"Enter the Paid Fees :- ";
cin>>fp;
fr=fee-fp;
}
void put()
{
cout<<"\nStudent Roll No. :- "<<rno;
cout<<"\nStudent Name is :- "<<sname;
cout<<"\nStudent Course Name :- "<<cname;
cout<<"\nTotal Course fees :- "<<fee;
cout<<"\nStudent Paid fees :- "<<fp;
cout<<"\nRemaining fees :- "<<fr;
}
};
void main()
{ clrscr();
admission a;
a.get();
a.put();
getch();
}
/*
Output :-
Enter The Roll No :- 13
Enter The Student Name :- Sham
Enter Course Name :- Java
Enter Total Fees :- 3200
Enter the Paid Fees :- 1500
Student Roll No. :- 13
Student Name is :- Sham
Student Course fees :- Java
Total Course fees :- 3200
Student Paid Fees :- 1500
Remaining fees :- 1700
*/