Question: Write a class called Zombie. It should have an instance (normal) data member of type string to hold the name of a Zombie. It should

Write a class called Zombie. It should have an instance (normal) data member of type string to hold the name of a Zombie. It should have a constructor that takes a string parameter and uses it to initialize the name. It should have a method called speak() that prints (if the Zombie is named Kevin), "Kevin says Braaaainss!" (use whatever the Zombie's actual name is). It should have a static data member that keeps track of how many Zombie objects have been created. When a Zombie is created, its constructor will need to increment the value in the static variable. In order to keep the count accurate when Zombies are destroyed, you will need a destructor to decrement the value in the static variable.

In your main function you should declare a vector of Zombie-pointers. You should give the user a menu in a loop. The options should be to: 1) create a new Zombie; 2) destroy a Zombie; 3) print the number of existing Zombies; 4) tell all existing Zombies to speak; or 5) quit. When a user chooses to create a new Zombie, you should dynamically allocate the new object and push its pointer onto the vector. When a user chooses to destroy a Zombie, you should pop the last Zombie pointer off the vector and deallocate the memory for that Zombie.

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!