Base Pointer to Derived Object
easyQuestion 130A 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, so print one after the last line.
Hints2 available
Sign in to use hintsTopics
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.