Object Oriented Programming - Old Questions
Question Answer Details
2. What is polymorphism in Object Oriented Programming? Implement a class Employee
with a virtual function CalculateSalary()
that returns the salary of the employee. Create two derived classes HourlyEmployee
and SalariedEmployee
. Override the CalculateSalary()
function in both derived classes to calculate the salary of an hourly employee and a salaried employee, respectively. Write a program that creates objects of both derived classes and calls the CalculateSalary()
function for each. [2+8]
Answer
AI Generated Answer
AI is thinking...