CJCoding With Joseph

Name Hiding in a Derived Class

When 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:
file
num

Do NOT write a main function.

Expected Output:

file
num
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.