Question
#include #include using namespace std; /* Create a Zoo. Randomly fill it with: 1-) Lion 2-) Bird 3-) Fish Include the following attributes for each
#include
Include the following attributes for each animal: Lion: Food type it lines Bird: Number of Eggs it lays every week Fish: How fast they swim
Then, display the Zoo statistics, counting how many of each animal we have.
Zoo size Max: 30 */
class Animal { public: virtual string gettype() = 0; };
class Lion : public Animal { public: string gettype() { return "Lion"; } };
class Fish : public Animal { public: string gettype() { return "Fish"; } };
class Bird: public Animal { public: string gettype() { return "Bird"; } };
void main() { Animal *Zoo[30];
Zoo[0] = new Lion(); Zoo[1] = new Bird(); Zoo[2] = new Fish();
for (int i = 0; i < 3; i++) cout << Zoo[i] << " " << Zoo[i]->gettype() << endl;
}
please c++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started