CJCoding With Joseph
15free / daySign inCreate account

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

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
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.