CJCoding With Joseph
15free / daySign inCreate account

Default Argument in Base Constructor

Create a base class Greeter and a derived class EnglishGreeter.

Greeter stores a protected string greeting and must have a constructor with a DEFAULT argument: Greeter(string g = "Hello") which sets greeting = g. A getGreeting() const method returns it.

EnglishGreeter has a default constructor EnglishGreeter() {} (already written). Because it does not pass anything to the base, the base's default argument is used.

The program prints the output shown in Expected Output.

Do NOT write a main function.

Expected Output:

Hello

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