/*
Multilevel Inheritance
*/
#include<iostream>
using namespace std;
class Person
{
protected:
int age;
char name[20],gender[20];
};
class Employee:public Person
{
protected:
int emp_id,salary;
char company[20];
};
class Programmer : public Employee
{
int no_of_prog_lang_know;
public:
void accept()
{
cout<<"\n\n Enter Name,Gender and age: ";
cin>>name>>gender>>age;
cout<<"\n\n Enter Employee id, Company name and Salary: ";
cin>>emp_id>>company>>salary;
cout<<"\n\n Enter number of programming language known: ";
cin>>no_of_prog_lang_know;
}
void display()
{
cout<<"\n Name: " <<name<<" Gender "<<gender<<" and age: "<<age;
cout<<"\n\n Employee id "<<emp_id<<" Company name "<<company<<" Salary: "<<salary;
cout<<"\n\n Number of programming language known: "<<no_of_prog_lang_know;
}
};
int main()
{
Programmer P;
P.accept();
P.display();
return 0;
}
Multilevel Inheritance
*/
#include<iostream>
using namespace std;
class Person
{
protected:
int age;
char name[20],gender[20];
};
class Employee:public Person
{
protected:
int emp_id,salary;
char company[20];
};
class Programmer : public Employee
{
int no_of_prog_lang_know;
public:
void accept()
{
cout<<"\n\n Enter Name,Gender and age: ";
cin>>name>>gender>>age;
cout<<"\n\n Enter Employee id, Company name and Salary: ";
cin>>emp_id>>company>>salary;
cout<<"\n\n Enter number of programming language known: ";
cin>>no_of_prog_lang_know;
}
void display()
{
cout<<"\n Name: " <<name<<" Gender "<<gender<<" and age: "<<age;
cout<<"\n\n Employee id "<<emp_id<<" Company name "<<company<<" Salary: "<<salary;
cout<<"\n\n Number of programming language known: "<<no_of_prog_lang_know;
}
};
int main()
{
Programmer P;
P.accept();
P.display();
return 0;
}