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
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
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 | string | full name of doctor |
age | int | age of person |
spec | string | speialization of doctor |
data members of patient
name | type | remarks |
name | string | full name of person |
age | int | age of he 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 2 steps with 1 images