โ Back to Inheritance
Question 430
Default Argument in Base Constructor
Default Argument in Base Constructor
Create a base classGreeterand a derived classEnglishGreeter.Greeterstores a protectedstring greetingand must have a constructor with a DEFAULT argument:Greeter(string g = "Hello")which setsgreeting = g. AgetGreeting() constmethod returns it.EnglishGreeterhas a default constructorEnglishGreeter() {}(already written). Because it does not pass anything to the base, the base's default argument is used. The program prints: Hello Do NOT write a main function.
Expected Output:
Hello
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.