Add a function herd() to the Zoo class you made for Exercises 15-2 or 15-3 that returns a vector with pointers to all Sheep in the Zoo. The Sheep remain part of the Zoo. Define a function called...


Add a function herd() to the Zoo class you made for Exercises 15-2 or 15-3 that returns a vector with pointers to all Sheep in the Zoo. The Sheep remain part of the Zoo. Define a function called shear() for Sheep that removes their wool. The function returns the weight of the wool after correctly adjusting the weight members of the Sheep object. Adjust the program of Exercise 15-2 so that it gathers all Sheep


using herd(), collects all their wool, and then outputs information in the Zoo again.


Hint: To extract an Animal* pointer from a given shared_ptr, you call the get() function of the std::shared_ptr template.


Extra: In this chapter, you learned about two different language mechanisms that could be used to herd() Sheep, that is, two techniques to differentiate Sheep* from other Animal* pointers. Try both (leaving one commented out).




May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here