Question: Consider the code snippet below: int main ( ) { Shape * shapes [ NUM _ OBJECTS ] ; shapes [ 0 ] = new

Consider the code snippet below:
int main()
{
Shape* shapes[NUM_OBJECTS];
shapes[0]= new Circle(0,0,100,150);
shapes[1]= new Rectangle(200,200,50,100);
shapes[2]= new Circle(300,50,250,250);
shapes[3]= new Rectangle(100,350,200,150);
for (int i =0; i < NUM_OBJECTS; i++)
{
shapes[i]->draw(draw_area);
}
for (int i =0; i < NUM_OBJECTS; i++)
{
delete shapes[i];
}
}
In order for pointers to the two different objects Circle and Rectangle to be put into the same array (shapes), what must be true?

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 Programming Questions!