Suppose, we have two related (child) classes named Doctor and Patient. Data members required by each class are given below. data members of doctors name type remarks name sring full name of the person age int age of the person spec string specialization of the doctor data members of patient. name type remarks name string full name of the person age int age of the person diag string diagnosed problem Using the information given above, create the following three classes. a. A parent class named Person containing common data members and functionality of the child classes; Doctor and Patient b. The class Doctor which is publicly inherited from the class Person c. The class Patient which is publicly inherited from the class Person Each class must contain at least two constructors in addition to the appropriate set() and show() functions. Functions of child classes should call appropriate functions of the parent class to perform the common functionality. All the function definitions should be written inside the class. Also provide a suitable main function to demonstrate the creation and usage of different objects of child classes.
Suppose, we have two related (child) classes named Doctor and Patient. Data members
required by each class are given below.
data members of doctors
name | type | remarks |
name | sring | full name of the person |
age | int | age of the person |
spec | string | specialization of the doctor |
data members of patient.
name | type | remarks |
name | string | full name of the person |
age | int | age of the person |
diag | string | diagnosed problem |
Using the information given above, create the following three classes.
a. A parent class named Person containing common data members and functionality of
the child classes; Doctor and Patient
b. The class Doctor which is publicly inherited from the class Person
c. The class Patient which is publicly inherited from the class Person
Each class must contain at least two constructors in addition to the appropriate set() and show() functions. Functions of child classes should call appropriate functions of the parent class to perform the common functionality. All the function definitions should be written inside the class. Also provide a suitable main function to demonstrate the creation and
usage of different objects of child classes.
Step by step
Solved in 3 steps with 1 images