CJCoding With Joseph
15free / daySign inCreate account

Polymorphic Employee Report

The starter gives an abstract base class Employee: a protected name, the constructor Employee(const string& name), and virtual void describe(ostream& out) const = 0;.

Write:
1. A free ostream& operator<<(ostream& out, const Employee& e) that calls e.describe(out) and returns out.
2. class Manager : public Employee, constructor Manager(const string& name, int reports); describe writes Manager , the name, a space, and the report count in parentheses followed by  reports — always plural, e.g. Manager Ann (3 reports) or Manager Cy (0 reports).
3. class Engineer : public Employee, constructor Engineer(const string& name, const string& lang); describe writes Engineer , the name, a space, and the language in square brackets, e.g. Engineer Bo [C++].

describe must NOT print a newline; the caller adds it. The tests keep the objects in a vector<Employee*> and print each one followed by a newline (see Expected Output).

Do NOT write a main function.

Expected Output:

Manager Ann (3 reports)
Engineer Bo [C++]
Engineer Di [Rust]
Manager Cy (0 reports)

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

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