CJCoding With Joseph
15free / daySign inCreate account

Polymorphic Array of Shapes

The abstract base class Shape declares a pure virtual area(). Complete BOTH derived classes:
- Square stores a side and its area() returns side times side
- Rectangle stores width and height and its area() returns width times height

The provided main stores both kinds in an array of Shape pointers and prints the total area — the correct area() is chosen for each object at runtime.

Expected Output:

29

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
Inheritance
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.