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
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