Question: C++ PROGRAMMING PLEASE REVISE MY CODE BELOW in your test program, create an array of type BasicShape with size 4 then populate array with 2

C++ PROGRAMMING

PLEASE REVISE MY CODE BELOW

in your test program, create an array of type BasicShape with size 4 then populate array with 2 Circle objects and 2 Rectangle objects. You can prompt use to enter values and then assign them to the array. Then define a function that will accept the array of BasicShape and in the function, and in a loop, print area of each object. What you should demonstrate here is Polymorphism since the type of the array is BasicShape.

Lastly, use pointers. That is an array of pointers to BasicShape and still of size 4.

#include

#include "Circles.h"

#include "Rectangles.h"

using namespace std;

void dispArea(Shapes* sh);

int main()

{

Circles *ptr = nullptr;

Circles cir(5, 2, 3.0);

ptr = ○

Rectangles *ptr1 = nullptr;

Rectangles rec(7, 8);

ptr1 = &rec;

dispArea(ptr);

dispArea(ptr1);

system("pause");

return 0;

}

void dispArea(Shapes* sh)

{

cout << sh->getAreas() << endl;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!