CJCoding With Joseph
15free / daySign inCreate account

Base Pointer to Derived Object

A base class Animal has been provided with a virtual function sound() that prints "Animal sound" and a virtual destructor.

A derived class Cat publicly inherits from Animal.

Your task is to override the sound() function in the Cat class so that it prints "Meow".

The test will create a Cat object through a base class pointer and call sound(). Because sound() is virtual, the derived version will be called. This is called polymorphism.

Do NOT include a main function. Your code will be tested automatically.

Expected Output:

Meow

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