Given the following classes, write the implementation codes and the driver program to demonstrate inheritance using C++. You may add other appropriate member functions and / or data members.
class DemoBasePerson
{
private: double salary; protected: int age; public: char initial; void setPerson(double, int, char); //sets values for salary, age and initial void showPerson( ); //displays values stored in salary, age and initial }; class Extrovert: public DemoBasePerson
{
private: string favSports; protected: double expenditure; public: int noOfEventsPerYear; void setExtro (string, double, int); //sets values for favSports, expenditure, noOfEventsPerYear //& data in the base class void showExtrovert( ); //displays values for favSports, expenditure, noOfEventsPerYear //& data in the base class
}; class Introvert: private DemoBasePerson
{
private: string passWord; protected: string loginId; public: string status;//active or passive void setIntro (string, string, string); //sets values for password, loginId, status //& data in the base class void showIntrovert( ); //displays values for passWord, loginId, status //& data in the base class
};
class SomeWhatShy: protected DemoBasePerson
{
private: string homeName; protected: string maritalStatus; public: string birthDate; void setSomeWhat(string, string, string); //sets values for homeName, maritalStatus, birthDate //& data in the base class void showSomeWhat( ); //displays values for homeName, maritalStatus, birthDate //& data in the base class
};
SOLUTION
#include<iostream>
#include<string>
using namespace std;
class DemoBasePerson
{
private: double salary; protected: int age; public: char initial;
void setPerson(){ double sal; int ag; char initi;