โ Back to Inheritance
Question 292
Polymorphic Salary Calculation
Polymorphic Salary Calculation
The base classEmployeehas atotalPay()method that returns baseSalary plus the result of the VIRTUAL methodbonus()(which returns 0 by default). Complete the derived classManagerso it overridesbonus()to return 1000. The key idea: totalPay() lives in the base class but calls the overridden bonus() at runtime. The provided main proves this by calling totalPay() on a Manager through an Employee pointer.
Expected Output:
6000
Topics:
Inheritance
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.