Q4. Polymorphism is a powerful OOP mechanism that brings a lot of flexibility to C++ code. Utilize this mechanism to make the given employee program flexible in calculating the yearly income for each employee by adding a new function named computeYIncome() that can be executed differently in each class as the following: Declare the function computeYIncome() in the employee class and make it an abstract class . Override above base class function in the subclasses to calculate the yearly income for the employee from the ExecOfficer and Worker types based on their specific attributes and return the result. In int main() function create an object from the type ExecOfficer, initialize its data members, then use the computeYIncome() function to display the yearly income for this executive officer employee.
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:
Q4.
Polymorphism is a powerful OOP
Utilize this mechanism to make the given employee program flexible in calculating the yearly income for each employee by adding a new function named computeYIncome() that can be executed differently in each class as the following:
Declare the function computeYIncome() in the employee class and make it an abstract class .
Override above base class function in the subclasses to calculate the yearly income for the employee from the ExecOfficer and Worker types based on their specific attributes and return the result.
In int main() function create an object from the type ExecOfficer, initialize its data members, then use the computeYIncome() function to display the yearly income for this executive officer employee.
Step by step
Solved in 2 steps with 1 images