Virtual Function With Return Value
mediumQuestion 144You are given a base class Employee with protected members name (string) and baseSalary (double), a constructor, and a virtual function calculatePay() that returns baseSalary.
Create two derived classes:
1. HourlyEmployee
- Inherits from Employee
- Has private double hoursWorked
- Constructor takes name, hourly rate (as baseSalary), and hoursWorked
- Override calculatePay() to return baseSalary * hoursWorked
2. BonusEmployee
- Inherits from Employee
- Has private double bonus
- Constructor takes name, baseSalary, and bonus
- Override calculatePay() to return baseSalary + bonus
Do NOT include a main function. Your code will be tested automatically.
Expected output
Alice: 800 Bob: 5500
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...