Define a class hierarchy with the following structure. You get to pick the problem domain, and I suggest you pick something you would like to work on in the future. Here are the details:

  • Define a class hierarchy with the following structure. You get to pick the problem domain, and I suggest you pick something you would like to work on in the future. Here are the details:
  • Derive three classes directly from your abstract base class and make them concrete by providing implementations for the virtual function you introduced in your abstract base class. The methods for each of these three classes must actually behave differently from one another (example: Circle area vs. Square area vs. Triangle area each use a different formula).
  • Write one interesting polymorphic function that operates on any type derived from your abstract base class. It should take a list (or array) of instances of your abstract base class (e.g., Shape *) and call the virtual function on each to do something interesting. Also, have each of these virtual functions print something so you can see which is being called.
  • Write a main program that builds a list (or array) of several instances of each of your concrete classes, then pass this off to your polymorphic function.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.