← Back to Abstract Classes
Question 175
Payroll System
Payroll System
Build a payroll system with the following class hierarchy: Payable (pure virtual base class):pay()andgetRole()are pure virtual. Staff (inherits from Payable): constructorStaff(string name)storesnameas a public member. FullTimeStaff (inherits from Staff): - ConstructorFullTimeStaff(string name, double monthlySalary)-pay(): prints"Paying [name]: [salary]"-getRole(): returns"Full-Time"ContractStaff (inherits from Staff): - ConstructorContractStaff(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 — 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.