← Back to Streams
Question 643
Polymorphic Employee Report
Polymorphic Employee Report
The starter gives an abstract base classEmployee: a protectedname, the constructorEmployee(const string& name), andvirtual void describe(ostream& out) const = 0;. Write: 1. A freeostream& operator<<(ostream& out, const Employee& e)that callse.describe(out)and returnsout. 2.class Manager : public Employee, constructorManager(const string& name, int reports);describewritesManager, the name, a space, and the report count in parentheses followed byreports— always plural, e.g.Manager Ann (3 reports)orManager Cy (0 reports). 3.class Engineer : public Employee, constructorEngineer(const string& name, const string& lang);describewritesEngineer, the name, a space, and the language in square brackets, e.g.Engineer Bo [C++].describemust NOT print a newline; the caller adds it. The tests keep the objects in avector<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
Sign in to use hintsTopics:
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.