← 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 overriddenbonus()at runtime. The provided main proves this by callingtotalPay()on a Manager through an Employee pointer.
Expected Output:
6000= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Inheritance
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.