C++ language
patient.h
/*preventing multiple inclusion of header files using#ifndef and #define directives */#ifndef PATIENT_H#define PATIENT_H#includeusing namespace std;class patient{ //declaring instance variables private: string firstName; string lastName; int id; public: //default constructor declaration patient(); //parameterized constructor declaration patient(string fName,string lName,int pId); //print() function declaration void print(); //setter functions declaration void setFirstName(string fName); void setLastName(string lName); void setId(int pId);};#endifpatient class implementationpatient.cpp#include "patient.h"//default constructor implementationpatient::patient(){ firstName=""; lastName=""; id=0;}//parameterized constructor implementationpatient::patient(string fName,string lName,int pId){ firstName=fName; lastName=lName; id=pId;}//print function implementationvoid patient:: print(){ cout<"first name:="">"first><><> cout<"second name:="">"second><><> cout<"id:>"id:><><>}//setter method to set firstName implementationvoid patient::setFirstName(string fName){ firstName=fName;}//setter method to set lastName implementationvoid patient::setLastName(string lName){ lastName=lName;}//setter method to set id implementationvoid patient::setId(int pId){ id=pId;}Extend thepatient class to include the following data members and methods i.e.,INHERITANCE.DEFINE AND IMPLEMENT (write the code for) the extended class. Class will be a name of your choice.Member variablemedical record number (i.e., the identifier of the last hospital providing care).Include member method includes, prototypes (declaration) and code (definition): all constructor(s), setmedical record number and print to extend the base class patient.Create an object of theinherited class that setsall member variables to values of your choice, i.e., use the extended class as you would in a test/client program. You do not need to write any other code in the test/client
patient class implementation
patient.cpp
#include "patient.h"//default constructor implementationpatient::patient(){ firstName=""; lastName=""; id=0;}//parameterized constructor implementationpatient::patient(string fName,string lName,int pId){ firstName=fName; lastName=lName; id=pId;}//print function implementationvoid patient:: print(){ cout<"first name:="">"first><><> cout<"second name:="">"second><><> cout<"id:>"id:><><>}//setter method to set firstName implementationvoid patient::setFirstName(string fName){ firstName=fName;}//setter method to set lastName implementationvoid patient::setLastName(string lName){ lastName=lName;}//setter method to set id implementationvoid patient::setId(int pId){ id=pId;}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here