//Virtual Base Class
#include <iostream>
#include<conio.h>
using namespace std;
class person
{
protected:
char name[20];
int age;
public:
void getdata()
{
cout<<"Enter name and age"<<endl;
cin>>name>>age;
}
void display()
{
cout<<"Name::"<<name<<endl;
cout<<"Age::"<<age<<endl;
}
};
class Employee: virtual public person
{
protected:
int eid,salary;
public:
void getdata()
{
cout<<"Enter Emp id and salary"<<endl;
cin>>eid>>salary;
}
void display()
{
cout<<"Emp ID::"<<eid<<endl;
cout<<"Salary::"<<salary<<endl;
}
};
class student: virtual public person
{
protected:
int sid;
char faculty[10];
public:
void getdata()
{
cout<<"Enter student ID and faculty"<<endl;
cin>>sid>>faculty;
}
void display()
{
cout<<"student ID:"<<sid<<endl;
cout<<"Faculty::"<<faculty<<endl;
}
};
class TA: public Employee, public student
{
char course[10];
public:
void getdata()
{
person::getdata();
Employee::getdata();
student::getdata();
cout<<"Enter Course"<<endl;
cin>>course;
}
void displaydata()
{
person::display();
Employee::display();
student::display();
cout<<"course::"<<course;
}
};
int main()
{
TA ta;
ta.getdata();
cout<<"----------------TechingAssistant Details-----------------"<<endl;
cout<<"***************************************************"<<endl;
ta.displaydata();
getch();
return 0;
}
Output
Saturday, February 6, 2016
- Saturday, February 06, 2016
- Unknown
- No comments
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment