Question: Create a simple program which uses the following class hierarchy: Parent class: animal (should be an abstract class) protected: String sound; // moo, quack, etc

Create a simple program which uses the following class hierarchy:

Parent class: animal (should be an abstract class)

protected: String sound; // "moo", "quack", etc unsigned int number_of_legs;

Three different child classes: (three different specific animals)

Requirements:

Each class must have its own .cpp and .h file, including constructors and destructors.

Write a main function which creates instances of the three animals

Use the vector and Map classes in the main function to store multiple instances of the animals. Find a way to use these classes.

Create a polymorphic function called displayanimaldata which prints all the data within each animal. This is not a member function in any class.

void displayanimaldata(animal * a) { a->displaydata(); }

Initialize the instances and call the displayanimaldata function to test polymorphism of the displaydata function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!