Override With Base Call and Extra Logic
mediumQuestion 142You are given a base class Logger with a virtual function log() that prints a timestamp message.
Create a derived class FileLogger that:
- Publicly inherits from Logger
- Has a private string member: filename
- Has a constructor taking a string filename
- Overrides log() to:
1. First call Logger::log() (to print the timestamp)
2. Then print "Saving to: [filename]"
This pattern is common in real software: the derived class extends (not replaces) the base behavior.
Do NOT include a main function. Your code will be tested automatically.
Expected output
[LOG] Timestamp recorded Saving to: output.txt
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
ClassesInheritance
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.