Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++ Reinforce and practice the concepts of Polymorphism and Inheritance. Create a base class called Figure that has the following characteristics: - Has two
In C++
Reinforce and practice the concepts of Polymorphism and Inheritance. Create a base class called Figure that has the following characteristics: - Has two elements (length and height) with access method protected (no private) OR - a get function that receives length and height and assigns them to their corresponding variables. - It is not a getter since they return each value separately, This method - It has an area method (of type float) that does not receive input arguments and that is declared using polymorphism. - For the base class in this example you can simply return 0. Create a class called Rectangle and derive it from the base class. You must have the - A public method called area that returns the area of the rectangle. Create a class called Triangle and derive it from the base class. You must have the - A public method called area that returns the area of the triangle. Create two pointer objects of the figure class (Rectangle and triangle) and for each of them create a new object of each of the derived classes 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