Question
Part 3 - Setup Virtual function to ENABLE the later selection of desired function in polymorphism Create an animal base class. string animalName; string sound;
Part 3 - Setup Virtual function to ENABLE the later selection of desired function in polymorphism Create an animal base class. string animalName; string sound; virtual animalSound() { cout << AnimalName << " says " << sound << endl; Create / SETUP 4 new derived classes based on animal, that OVERRIDE the virtual function, animalSound, with the specific animal noise, and assign the animal name to the base animal name variable. cat dog elephant mouse Declare instances of each of the 4 different animals. C1, D1, E1, M1. Write a switch statement that prints out the animal noise, depending on which animal is chosen. prompt the user for the type of animal, compare with switch statement, and print out animal sound.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started