CJCoding With Joseph
15free / daySign inCreate account

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 the output shown in Expected Output.

Do NOT write a main function.

Expected Output:

file
num

= 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.