Answer to Question #209937 in C++ for hariss

Question #209937

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.

b) Recall the Complex class that we implemented in operator overloading concept. Your task is to

provide implementation of the following method. friend ostream& operator<< (ostream& , const

Complex& )


1
Expert's answer
2021-06-23T07:01:40-0400
#include<iostream>
using namespace std;
class Medical_Staff{
	private:
		int staff_id;
	public:
		
		int staff_input(){
			cin>>this->staff_id;
			return staff_id;
		}
		void staff_show(){
			cout<<"The staff id is: \t "<<this->staff_id<<endl;
		}
};
class Doctor: public Medical_Staff{
	private:
	int PMDC_number;
	public:
		
			int doctor_input(){
			cin>>this->PMDC_number;
			return PMDC_number;
		}
		void doctor_show(){
			cout<<"The PMDC number is: \t "<<this->PMDC_number<<endl;
		}
};
class Skin_Specialist: public Doctor{
	private:
		int experience;
	public:
			int skin_input(){
			cin>>this->experience;
			return experience;  
		}
		void skin_show(){
			cout<<"The experience is: \t "<<this->experience<<endl;
		}
		
};
int main(){
	//Testing the multi-level inheritance using the grand child object
	Skin_Specialist  skin;
	 cout<<"Enter staff id\n"<<endl;
	 skin.staff_input();
	 cout<<"Enter the PMDC number of the doctor"<<endl;
	 skin.doctor_input();
	 cout<<"Enter the experience of the skin specialist"<<endl;
	 skin.skin_input();
	 
	 skin.staff_show(); 
	
	 skin.doctor_show();
	 
	 skin.skin_show();


	
}

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