Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions