Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

Define data independence.

Answered: 1 week ago

Question

What are oxidation and reduction reactions? Explain with examples

Answered: 1 week ago