Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[09/01, 21:29] Bro: #include #include using namespace std; #ifndef DOCTOR_H #define DOCTOR_H class Doctor{ private: int ID_; string name_; int salary_; public: Doctor(); ~Doctor(); Doctor(int

[09/01, 21:29] Bro: #include #include using namespace std;

#ifndef DOCTOR_H #define DOCTOR_H

class Doctor{

private: int ID_; string name_; int salary_;

public: Doctor(); ~Doctor(); Doctor(int ID, string name,int salary ); void setName(string name); string getName(); void setID(int ID); int getID(); void setSalary(int salary); int getSalary(); void printDetails();

};

#endif [09/01, 21:29] Bro: #include #include #include "doctor.h" using namespace std;

Doctor::Doctor(){ setSalary(0); setID(0); setName("No_Name"); } Doctor::~Doctor(){} Doctor::Doctor(int ID, string name,int salary ){ setSalary(salary); setID(ID); setName(name); } void Doctor::setName(string name){ name_=name; } string Doctor::getName(){ return name_; } void Doctor::setID(int ID){ ID_=ID; } int Doctor::getID(){ return ID_; } void Doctor::setSalary(int salary){ salary_=salary; } int Doctor::getSalary(){ return salary_; }

void Doctor::printDetails(){ cout #include #include "doctor.h" using namespace std;

class hospital{ int id; string Hloc; int nod; Doctor *doctors; public: hospital(int hn,string loc); hospital(const hospital &h); ~hospital(); void setDoctors(Doctor *n,int num_of_doctors); int GetTotalSalaries(); friend void removeDoctorFromHospital(hospital & ch,int i); friend void printDetails(hospital &e);

}; [09/01, 21:30] Bro: #include #include #include "doctor.h" #include "hospital.h" using namespace std;

hospital::hospital(int hn,string loc){ this->id=hn; this->Hloc=loc; nod=0; this->doctors=NULL; } hospital::hospital(const hospital &h){ id=h.id; Hloc=h.Hloc; nod=h.nod; doctors=new Doctor[nod]; for(int i=0;i #include #include "doctor.h" #include "hospital.h" using namespace std;

int main() { hospital hospital1(1,"Amman"); Doctor d[3]; int id,salary; string name; for(int i=0;i>id>>name>>salary; d[i].setID(id); d[i].setName(name); d[i].setSalary(salary); }

hospital1.setDoctors(d,3);

hospital hospital1copy(hospital1); removeDoctorFromHospital(hospital1,1); printDetails(hospital1); printDetails(hospital1copy);

image text in transcribed

add to the previous code these things that in the picture

}

You will practice in this lab with friend functions and classes 1. Define a friend function printDetails(Hospital& e) to print the details of the Hospital 2. Define a friend function removeDoctorFromHospital(Hospital& current Hospital, int i): this function removes the ith Doctor from the array Doctors in the current Hospital object and shifts remaining Doctors, i should be in a proper range

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions