CJCoding With Joseph
15per day

Virtual Function With Return Value

You 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

Expected Output:

Alice: 800
Bob: 5500
Topics:
ClassesInheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.