Question: Create two objects: a rectangle and a square. Also, create a rectangle pointer named rptr and initialize it to nullptr. Then: point the rptr pointer

Create two objects: a rectangle and a square. Also, create a rectangle pointer named rptr and initialize it to nullptr. Then:

  • point the rptr pointer to the rectangle object and use it to call the getName() function.
  • point the rptr pointer to the square object and use it to call the getName() function.

Step by Step Solution

3.50 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To achieve this you would need to have a class hierarchy where both the Rectangle and Square classes ... View full answer

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