โ Back to Inheritance
Question 431
Using the Override Keyword
Using the Override Keyword
Create a base classBirdwith a virtual methodstring sound() constthat returns "generic". Create a derived classSparrowthat overridessound()to return "chirp". Mark the override with theoverridekeyword. When called through aBird*that points to aSparrow, the program prints: chirp Do NOT write a main function.
Expected Output:
chirp
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.