โ Back to Inheritance
Question 6
Dog Extends Animal
Dog Extends Animal
AnAnimalbase class is provided by the tester. It has a publicNamefield, a constructorAnimal(string name), and avirtual string Speak(). Create a classDogthat inherits fromAnimal, passes the name to the base constructor, and OVERRIDESSpeak()to return "Woof". Do NOT write aMainmethod. For a Dog named Rex the program prints: Rex says Woof
Expected Output:
Rex says Woof
Topics:
Inheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.