Answer to Question #199297 in C++ for faizan

Question #199297

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.


1
Expert's answer
2021-05-27T19:09:50-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog