Question: I would like to know how to do it by C++ STL Map. Not vector pls. Thank you very much. You are to create a

I would like to know how to do it by C++ STL Map. Not vector pls. Thank you very much.

You are to create a base class called Animal, using the files animal.h and animal.cpp. You should then create a derived, or child class called Cow. You should create the definition of the class Cow in a file cow.h and the functions for Cow in cow.cpp. You will also create a main program to be housed in cowmain.cpp. A Cow will have attributes as follows. Those attributes indicated with a should be in the base class Animal and inherited by the Cow class.

Breed (string)

Weight (float)

Name (string)" Gender ('m' or 'f')

Spayed or neutered (yes/no)

Registration ID (alphanumeric like HZ123X)

Color description (this could be more than a single word)

Other comments (also more than a single word)

Both Animal and Cow will have the following methods:

Accessors for all attributes

Mutators for all attributes A default constructor that sets all data elements to 0 or blank text as appropriate

A fully specified constructor that allows defining values for all attributes. The Cow constructor should obtain all needed data and provide necessary data to the Animal Constructor automatically.

A display method that will display all the info for a cow in a logical and well formatted way including labels for each of the attribute fields. The display method should be a virtual function in Animal that is overridden in Cow. The Cow display should use the functionality of the Animal display function. cowmain.cpp should perform the following actions

Dynamically allocate a vector to hold 3 Cows. Note that you will have to allocate the vector to be of Animal pointers in order for the virtual function to operate properly

Prompt the user for information about each of the three cows and store that information in one of the vector elements in the appropriate class levels

Print the information for each Cow using an iterator

Clean up all allocated space

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!