Design a class named Staff that includes A data member named staffID A parameterized constructor to initialize staffID A getter function to get the value of staffID Derive a class named doctor inherited from Staff class and contains Two additional data members i.e. departmentID and departmentName A parameterized constructor to initialize its own data fields along with the inherited data field Two getter functions that return the departmentID and departmentName, respectively Derive a class named VisitingDoctor inherited from class Doctor and has A data field named no_of_patients A data field named fee_per_patient A function named totalSalary that returns total payment for all patients A member function named display to show total salary of visiting doctor. A member function name datawrite in which you write all the information against visiting doctor in a text file. The name of the file is your name.
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
class Staff
{
int staffID;
public:
Staff(int n)
{
staffID=n;
}
int getstaffID()
{
return staffID;
}
};
class doctor : public Staff
{
int departmentID;
string departmentName;
public:
doctor(int id, int diD, string nm) : Staff{ id }
{
departmentID=diD;
departmentName=nm;
}
int access_departmentID()
{
return departmentID;
}
string access_departmentName()
{
return departmentName;
}
};
class VisitingDoctor : public doctor
{
int no_of_patients;
float fee_per_patient;
public:
float totalSalary()
{
return no_of_patients*fee_per_patient;
}
void Display()
{
cout<<"Salary of visiting doctor : "<<totalSalary();
}
};
int main()
{
int n;
Staff s1(2345);
doctor(1233,234,"name");
return 0;
}
Comments
Leave a comment