Question: Write a complete C++ program, using classes that implements polymorphism in order to create the following output: Let's populate your farm Please choose 4 animals
Write a complete C++ program, using classes that implements polymorphism in order to create the following output:
Let's populate your farm
Please choose 4 animals :
(1)dog (2)sheep (3)horse (4)pig: 1
Mammal constructor...
Dog constructor
(1)dog (2)sheep (3)horse (4)pig: 2
Mammal constructor...
Sheep constructor
(1)dog (2)sheep (3)horse (4)pig: 3
Mammal constructor...
Horse constructor
(1)dog (2)sheep (3)horse (4)pig: 4
Mammal constructor...
Pig constructor
WOOF
BAA
NEIGH
OINK
Dog destructor
Mammal destructor..
Sheep destructor
Mammal destructor...
Horse destructor
Mammal destructor...
Pig destructor
Mammal destructor...
Program ended with exit code: 0
Use the mammal class developed below as the base class and create 4 subclasses for dog, horse, sheep and pig derived objects to be stored in a Mammal array farm[4]; Each mammal should call its own Speak() function.
Place your classes and driver in one file.
#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
