Write A Program In OOp for Multiple Inheritance

7/12/2013 02:59:00 pm Unknown 0 Comments

#include<iostream>
#include<conio.h>
#include<string.h>
using namespace std;
class person
{
string name , fathername;
int age;
public:
void get()
{
cout<<"Enter Your Name: "<<endl;
cin>>name;
cout<<"Enter Father Name: "<<endl;
cin>>fathername;
cout<<"Enter Your Age "<<endl;
cin>>age;

}
void put()
{
     cout<<"name: "<<name<<endl;
     cout<<"father name: "<<fathername<<endl;
     cout<<"age is "<<age<<endl;  
    }



};
class employee: public person
{
int salary;
public:
void get()
{
person::get();
cout<<"Enter Salary"<<endl;
cin>>salary;

}
void put()
{
     person::put();
cout<<"\nsalary is "<<salary;  
}
};
class teacher : public employee
{
string main_subject;
public:
void get()
{
employee::get();
cout<<"Enter main Subject "<<endl;
cin>>main_subject;

}
void put()
{
person::put();
cout<<"main subject is "<<main_subject;  
}
};
int main()
{

person p1;
cout<<"Enter Data for Person"<<endl;
p1.get();
employee e1;
cout<<"\nEnter Data for employee"<<endl;

e1.get();

teacher t1;
cout<<"\nEnter Data for Teacher"<<endl;
t1.get();
cout<<"\n Data for Person"<<endl;
p1.put();
cout<<"\n*****************"<<endl;
cout<<"\n Data for employee"<<endl;
e1.put();
cout<<"\n*****************"<<endl;
cout<<"\n Data for Teacher"<<endl;
t1.put();
cout<<"\n*****************"<<endl;
getch();

}

// getline(cin,data types);
//it is used to write a name with space for example Ammar nisar ,you use instead of cin in dev c++
//in turbo c++use as getline(data type,size);