Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. InheritanceUsing the Tree Class With the Tree base class and derivedclasses O

ID: 3618575 • Letter: 1

Question

1. InheritanceUsing the Tree Class

With the Tree base class and derivedclasses Oak and Pine, you can explore the concept ofpolymorphism. Write a main() driver function that createsa Tree object, an Oak object, and a Pine object. Then create abase class pointer named treePtr, i.e., one that points toa Tree object. Then, in turn, assign the address of each object totreePtr and call showSymbol() using either of the followingmethods:

(*treePtr).showSymbol(cout);

or

treePtr->showSymbol(cout);

Did you get the correct symbol foreach tree? If not, modify the declaration part of theTree class sothat showSymbol() gives the correct symbol for each object,illustratingpolymorphism.

Explanation / Answer

http://www.codeproject.com/KB/architecture/treedata_class.aspx hope this help