Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Subject Write a complete C++ program and create a class tree shown in Figure 1. For each class in the tree, first write code for
Subject Write a complete C++ program and create a class tree shown in Figure 1. For each class in the tree, first write code for the non-argument constructor that prints out the class name. Then add one private property for each nimal growO class and corresponding get and set methods. Then split the code for definition and code for wo implementation into a header file and a source file displayO respectively. Plus the additional source file TestCreature.cpp with main() function, there should be Creature growO displayO Plant displayO growo Grass Insect growO Pine growo Parsle Fly displayO 19 files display) Figure 1 In addition, follow the instruction in Figure 1 and add growO and display) methods to specified classes. For each growO, print with clear prompt text 1) Annual growth rate in unit of inch 2) Host class name For any display) method, print the host class name and the current value of its own property and the property of its every ancestor class. If an ancestor had display), call display. If an ancestor does not have displayO, call its property's get method. Note one property should only be printed once. In the main() function, create one object from each class in the above class tree. Then call both growO and display) methods from each object created. The code of creating object of a certain class should immediately proceed the code to call this class's two methods. In other words, the code of one object should be together. The order of creating and using object should be top-down and then left-to-right n one row The printout should confirm to following rules of dynamic binding or polymorphism 1) On the path from current class to the root (common ancestor) 2) Closest 3) Never go downward Otherwise, each incorrect printout of an grow) or display) method will be deducted 5 points
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