Question: short c++ question: Code Writing The Animal class is a superclass for Animal objects, and it has the public member methods virtual void eat(), virtual

short c++ question:

short c++ question: Code Writing The Animal class is a superclass for

Code Writing The Animal class is a superclass for Animal objects, and it has the public member methods virtual void eat(), virtual void sleep(), and virtual std::string getStatus(). getStatus will always return either hungry, sleepy", or happy. Write a void function that takes an array of Animal pointers and its size as parameters. If any pointer in the array is pointing to nullptr, throw an instance of std::runtime_error. Otherwise, for each Animal pointer in the array, if the Animal that is being pointed to has a status of hungry, call eat() on it. If its status is sleepy, call sleep on it. If its status is happy, do not call any methods on it. #include "Animal.h" #include //your code here

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!