Name Hiding in a Derived Class
mediumQuestion 441When a derived class declares ANY method with a given name, it hides ALL base methods of that same name (even overloads with different parameters).
Base class Logger (already written) has two overloads: string write() const returning "base", and string write(int n) const returning "num".
Create a derived class FileLogger that declares its own string write() const returning "file". This hides the base write(int), so it can only be reached with the qualified name Logger::write(int).
The runner calls f.write() and f.Logger::write(3) and prints the output shown in Expected Output.
Do NOT write a main function.
Expected output
file num
= newline. The output ends with a newline, so 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.