Saturday, February 6, 2016

//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


 







0 comments:

Post a Comment

Translate

Sample Text

Powered by Blogger.

Every thing is possible in real world....

Contact us

Name

Email *

Message *

IT Support

Blogroll

You can replace this text by going to "Layout" and then "Page Elements" section. Edit " About "

Video

Our Facebook Page

Popular Posts

Total Pageviews