#include<iostream.h> #include<conio.h> class institution { protected: char insname[20]; int noy; public: void getdata() { cout<<"Enter Name of Institution:- "; cin>>insname; cout<<"Enter Establishment Year:- "; cin>>noy; } void outdata() { cout<<"\nName of Institution:- "<<insname; cout<<"\nYear of Establishment:- "<<noy; } }; class teacher:public institution { protected: char dept[20]; int noc; public: void getdata() { institution::getdata(); cout<<"Enter Name of Department:- "; cin>>dept; cout<<"Enter Alloted Class:- "; cin>>noc; } void outdata() { institution::outdata(); cout<<"\nName of Department:- "<<dept; cout<<"\nNo of Alloted Class:- "<<noc; } }; class student:public teacher { private: int rn; char grade; public: void getdata() { teacher::getdata(); cout<<"Enter Roll No:- "; cin>>rn; cout<<"Enter Grade:- "; cin>>grade; } void outdata() { teacher::outdata(); cout<<"\nRoll No:- "<<rn; cout<<"\nGrade:- "<<grade; } }; void main() { clrscr(); student s; s.getdata(); s.outdata(); getch(); }
Advertisements