โ Back to Inheritance
Question 441
Name Hiding in a Derived Class
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 classLogger(already written) has two overloads:string write() constreturning "base", andstring write(int n) constreturning "num". Create a derived classFileLoggerthat declares its ownstring write() constreturning "file". This hides the basewrite(int), so it can only be reached with the qualified nameLogger::write(int). The runner callsf.write()andf.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.