Question: I have the main files done just need help with the following: Animal.h #pragma once #include #include #include using namespace std; class Animal { string

I have the main files done just need help with the following:

I have the main files done just need help with the following:

Animal.h #pragma once #include #include #include using namespace std; class Animal {

Animal.h

#pragma once #include #include #include

using namespace std;

class Animal { string name; int age;

public:

Animal() { cout

void display(const vector & list) {

}

string getName() { return name; }

void setName(string name) { this->name = name; }

int getAge() { return age; }

void setAge(int age) { this->age = age; }

~Animal() { cout

void feed() { cout

};

Dog.h

#ifndef LA4_Dog_h #define LA4_Dog_h

#include #include "Animal.h"

using namespace std;

class Dog : public Animal{ public: Dog(){ cout

#endif

display.h

#include "Animal.h" void display (const vector &list){ for (int i = 0; i getName() Suppose we wish to store several different animals in an array. We do not know ahead of time what animals they will be. C++ will allow us to create a vector of pointers to Animal, and store in that vector, any object of type Animal or a descendant of Animal. So, if we have a generic animal we can store it as a generic animal but if we have a dog we can store it as a dog. Reuse the Animal.h and Dog.h files from previous exercises and get the display.h file. Then write a C++ program that reads in an integer N. This is followed by N lines, where each line contains a character, a string and an integer, separated by space. The character will either have the value A or D, indicating whether the animal described on this line is a generic animal or a dog. The string indicates the animal's name and the integer, its age. For each line of input, instantiate the appropriate object and push it to the vector of pointers to Animal that you have created. Once you have pushed all the animals to the vector, call the display function, found in display.h, with your vector passed as an argument. For example, if input (marked as bold) is entered, you should see following Output: 2 A Snoopy 4 Creating Generic Animal D Bruno 5 Creating Generic Animal Creating Dog Snoopy Bruno

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!