CJCoding With Joseph
15free / daySign inCreate account

You are given a base class Shape with a protected string color and a constructor.

Create a derived class Rectangle that: - Publicly inherits from Shape - Has private members: double width and double height - Has a constructor that takes color, width, and height (use initialization list to call base constructor and set both members) - Has a function getArea() that returns width * height - Has a function describe() that prints: "[color] Rectangle: [area]"

For example, a red rectangle with width 5 and height 3 should print the output shown in Expected Output.

Do NOT include a main function. Your code will be tested automatically.

Expected output

red Rectangle: 15

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

Hints4 available
Topics
ClassesInheritance
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.