Answer to Question #209930 in C++ for umair

Question #209930

a) Write a class Medical Staff that contains an attribute ID to store staff’s identity. The class contains member functions to input and display ID. Write a child class Doctor that inherits Medical Class. It additionally contains an attribute to store doctor’s PMDC number. It also contains member functions to input and show the PMDC number. Write another class Skin Specialist that inherit Doctor Class. It additionally contains an attribute to store working experience as specialist. It also contains member functions to input and show the experience. Test these classes from main() by creating objects of derived classes and testing functions in a way that clear concept of multi-level Inheritance.



1
Expert's answer
2021-06-23T17:08:14-0400
#include <stdio.h>
#include <iostream>


using namespace std;


class MedicalStaff{
    string ID;
    public:
    void getID(string id){
        ID = id;
    }
    void showID(){
        cout<<"ID: "<<ID<<endl;
    }
};
class Doctor: public MedicalStaff{
    protected:
    string PMDC;
    public:
    void getPMDC(string pm){
        PMDC = pm;
    }
    void showPMDC(){
        cout<<"PMDC: "<<PMDC<<endl;
    }
    
};
class SkinSpecialist: public Doctor{
    string experience;
    public:
    void getEXP(string expr){
        experience = expr;
    }
    void showEXP(){
        cout<<"Experience: "<<experience<<endl;
    }
};


int main()
{
    // Instantiate using parent class
    MedicalStaff medstaff;
    medstaff.getID("1");
    medstaff.showID();
    cout<<endl;
    // Instatiating object using sub-classes (Doctor)
    Doctor dr;
    dr.getPMDC("11212761");
    dr.showPMDC();
    dr.getID("2");
    dr.showID();
    cout<<endl;
     // Instatiating object using sub-classes (Doctor)
    SkinSpecialist sdr;
    sdr.getPMDC("6734534");
    sdr.showPMDC();
    sdr.getID("3");
    sdr.showID();
    sdr.getEXP("10yrs");
    sdr.showEXP();
    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
APPROVED BY CLIENTS