Question: #include #include #include using namespace std; class Animal { private: string name; string sound; public: Animal(const string n=,const string s=); string getName() const; string makeSound()

#include #include #include using namespace std;

class Animal { private: string name; string sound; public: Animal(const string n="",const string s=""); string getName() const; string makeSound() const; friend ostream& operator<< (ostream& os,const Animal& a); };

Animal::Animal(const string n,const string s) { name=n; sound=s; }

string Animal::getName() const{ return name; }

string Animal::makeSound() const{ return sound; }

ostream& operator<<(ostream& os,const Animal& a){ string s=a.name+" says "+a.sound; os << s; return os; }

class Exhibit { public: Exhibit(int maxEnt = 10); ~Exhibit(); void add(const Animal& a); Animal& operator[](size_t i) {return entries[i];} friend ostream& operator<<(ostream& out,const Exhibit& obj); private: int MaxNumberOfAnimals; int CurrentNumberOfAnimals; Animal* entries; };

Exhibit::Exhibit(int maxEnt) { MaxNumberOfAnimals=maxEnt; CurrentNumberOfAnimals=0; entries=new Animal[maxEnt]; }

Exhibit::~Exhibit() {

} void Exhibit::add(const Animal& a){

if(CurrentNumberOfAnimals

os << s; return os; }

int main() { Animal* monkey = new Animal("Max","Eeeeep"); Animal* tiger = new Animal("Jack","Roar"); Animal* Dog = new Animal("Petals","Woof"); cout<<*monkey<

//cage.removeLast();

cout<

//cage.removeLast();

cout <

how would i edit this code to produce this output using void removeLast() function in the Exhibit class (I have provided what needs to be in the code in the comments):

Frank says Squeak

Simba says Chuff

Petels says Woof

{ Frank Simba Batty Hippopotamusesy Turkey }

{ Frank Simba Batty Hippopotamusesy }

{ Frank Simba Batty }

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!