#include<iostream>
using namespace std;
class person
{
private:
char name[20];
long int rollno;
char sex;
public:
void getdata();
void display();
};
class student {
private:
char course[20];
char semester[10];
int rank;
public:
void getdata();
void display();
};
class Employee : private person,private student
{
private:
float amount;
public:
void getdata();
void display();
};
void person :: getdata()
{
cout<<"enter a name?\n";
cin>>name;
cout<<"enter roll no \n";
cin>>rollno;
cout<<"sex?\n";
cin >>sex;
}
void person::display()
{
cout<<name<<" ";
cout<<rollno<<" ";
cout<<sex<<" ";
}
void student ::getdata()
{
cout<<"course name\n";
cin>>course;
cout<<"semester\n";
cin>>semester;
cout<<"rank of the student\n";
cin>>rank;
}
void student :: display()
{
cout <<course<<" ";
cout <<semester<<" ";
cout <<rank<< " ";
}
void Employee :: getdata()
{
person:: getdata();
student :: getdata();
cout<<"amount in rupees?\n";
cin>>amount;
}
void Employee :: display()
{
person :: display();
student::display();
cout<<amount<<" ";
}
int main()
{
Employee f;
cout<<"enter the following information for";
cout<<"financial assistance\n";
f.getdata();
cout<<endl;
cout<<"____________________________________________\n";
f.display();
cout<<endl;
cout<<"_____________________________________________\n";
}
Comments
Leave a comment