Payroll System
hardQuestion 175Build a payroll system with the following class hierarchy:
Payable (pure virtual base class): pay() and getRole() are pure virtual.
Staff (inherits from Payable): constructor Staff(string name) stores name as a public member.
FullTimeStaff (inherits from Staff):
- Constructor FullTimeStaff(string name, double monthlySalary)
- pay(): prints "Paying [name]: [salary]"
- getRole(): returns "Full-Time"
ContractStaff (inherits from Staff):
- Constructor ContractStaff(string name, double hourlyRate, int hours)
- pay(): prints "Paying [name]: [hourlyRate * hours]"
- getRole(): returns "Contract"
Do NOT write a main function.
Expected output
Paying Alice: 3000 Full-Time Paying Bob: 1500 Contract
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Abstract Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.