Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++ write a program , Lab10.cpp is given Lab10.cpp: #include #include using namespace std; // Base class personType class personType { public: void print()const;
In C++ write a program ,
Lab10.cpp is given
Lab10.cpp:
#include
#include
using namespace std;
// Base class personType
class personType
{
public:
void print()const;
//Function to output the first name and last name
//in the form firstName lastName.
void setName(string first, string last);
string getFirstName()const;
string getLastName()const;
personType(string first = "", string last = "");
//Constructor
//Sets firstName and lastName according to the parameters.
//The default values of the parameters are null strings.
//Postcondition: firstName = first; lastName = last
private:
string firstName; //variable to store the first name
string lastName; //variable to store the last name
};
void personType::print() const
{
cout
}
void personType::setName(string first, string last)
{
firstName = first;
lastName = last;
}
string personType::getFirstName() const
{
return firstName;
}
string personType::getLastName() const
{
return lastName;
}
//constructor
personType::personType(string first, string last)
{
firstName = first;
lastName = last;
}
// --------------------Start your code from here
//--------------------driver program
int main()
{
personType person1("Lisa", "Regan");
doctorType doctor1("Sarah", "Conner", "Dentist");
patientType patient1("Sam", "Fire",200,100,1916);
billType b1(doctor1, patient1);
b1.setCharge(250.66);
cout Printing... ";
person1.print();
cout
cout Printing... ";
doctor1.print();
cout
cout Printing... ";
patient1.print();
cout
Download Lab10.cpp. In this file, the definition of the class personType has given. Think of the personType as the base class. Questionl (Inheritance) Type, with an additional class Derive the class doctorType, inherited from the class member variable member to store a doctor's specialty(string type) Then, implement following class member function prototypes. person doctorType(string.string.string)://Firstname Lastname Specialty doctorTypeO:l/Default constructor void setSpecialty(string):l/Set doctor specialty string getSpecialtyOconst:// Get doctor specialty void printOconst://Display doctor information the same as given output format Derive the class patientType, inherited from the class personType, with additional class member variables to store a patient's id, age, and dob (all are integers). Then, implement following class member function prototypes patient Typelstring, string, int, int, int)://Firstname Lastname id age dob patient TypeO:Default constructor void setld(int)://Set patient id void setage(int):l/Set patient age void setDobfint);Set patient DOB int getld0constl/Get patient id int getageOconst://Get patient int getDobOconst://Get patient DOB void print const;/Display patient information the same as given output format cout Printing... ";
b1.print();
cout
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started