Subject: Polymorphism
Write a complete C++ program (ONE FILE) and create 8 classes that form a class tree as shown in Figure. Every class has only one no-argument constructor and no properties. Each class may have an "eato" method and/or a "growO" method. Both methods have no return value and no parameters. Inside any no-argument constructor, any "eato" method, or any "growO" method, there is only one output statement to print "constructor of xxx class", "eatO method of xxx class", or "growO method of xxx class", respectively. Here, "xxx" represents the current class.
Animal
eat()
grow()
Fish
eatO()
Mammal
Sardine
grow()
Bass
eatO()
Cat
eatO()
grow()
Tiger
Lion
eatO()
Figure
Add a line break at the end of the printout.
Add another function above, "mainO", with the given code below.
void display(Animal& al) {
al.eat();
al.grow();
}
In the "mainO" function, create one object for each leaf class, i.e. classes Sardine, Bass, Tiger, and Lion. Then call both "eat()" and "growO()" from each object.
(There is no need to split the code due to the simplicity of all classes. Place all 8 classes, main function, and all other functions in a single source file, i.e., upload one .cpp file)