// Q.21 WAP to manage a firm having Employees of different type using
   // inheritance

   #include
   #include
   #include

   class Employee
	{
	private:
		char name[50];
		char age;
		char desig[60];
	public:
		void get_data()
			{
			cout << "Enter Name          : "; gets(name);
			cout << "\nEnter Age         : "; cin >> age;
			cout << "\nEnter Designation : "; gets(desig);
			}
		void disp_data()
			{
			cout << "Name          : "  << name;
			cout << "\nAge         : "  << age;
			cout << "\nDesignation : "  << desig;
			}
	};

   class Accountant : public Employee
	{
	private:
		int salary;
		char exp[60];
	public:
		void get_data()
			{
			Employee::get_data();
			cout << "\nEnter Salary     : " ; cin >> salary;
			cout << "\nEnter Experience : "; gets(exp);
			}
		void disp_data()
			{
			Employee::disp_data();
			cout << "\nSalary     : " << salary;
			cout << "\nExperience : " << exp;
			}
	};
   class Engineer : public Employee
	{
	private:
		int salary;
		char exp[60];
		char qualif[60];
	public:
		void get_data()
			{
			Employee :: get_data();
			cout << "\nEnter Salary        : " ; cin >> salary;
			cout << "\nEnter Experience    : " ; gets(exp);
			cout << "\nEnter Qualification : "; gets(qualif);
			}
		void disp_data()
			{
			Employee::disp_data();
			cout << "\nSalary         : " << salary;
			cout << "\nExperience     : " << exp;
			cout << "\n1Qualification : " << qualif;
			}
	};
   class Scientist : public Employee
	{
	private:
		int salary;
		char exp[60];
		char achv_mts[100];
	public:
		void get_data()
			{
			Employee::get_data();
			cout << "\nEnter Salary       : "; cin >> salary;
			cout << "\nEnter Experience   : "; gets(exp);
			cout << "\nEnter Achievements : "; gets(achv_mts);
			}
		void disp_data()
			{
			Employee::disp_data();
			cout << "\nSalary       : " << salary;
			cout << "\nExperience   : " << exp;
			cout << "\nAchievements : " << achv_mts;
			}
	};
   void main()
	{
	clrscr();
	int ch;
	Accountant A1;
	Engineer E1;
	Scientist S1;

		  cout << "Enter Details for Employee\n";
		  A1.get_data();
		  cout << "\n";
		  cout << "Enter Details for Engineer\n";
		  E1.get_data();
		  cout << "\n";
		  cout << "Enter Details for Scientist\n";
		  S1.get_data();
		  cout << "\n**********************\n";
		  cout << "\nAccountant\n";
		  A1.disp_data();
		  cout << "\n";
		  cout << "\nEngineer\n";
		  E1.disp_data();
		  cout << "\n";
		  cout << "\nScientist\n";
		  S1.disp_data();
		  cout << "\n";
		  getch();
	}






    Source: geocities.com/cplusplussurvivalkit