CJCoding With Joseph

Polymorphic Salary Calculation

The base class Employee has a totalPay() method that returns baseSalary plus the result of the VIRTUAL method bonus() (which returns 0 by default). Complete the derived class Manager so it overrides bonus() 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.