Menu

Question 4 10 Marks Implement Three Classes Shape Square Rectangle Square Represents Squar Q43786464

Question # 4 (10 marks) Implement three classes Shape, Square, and Rectangle, such that Square represents a square (with a wi

Using OOP in c++

Question # 4 (10 marks) Implement three classes Shape, Square, and Rectangle, such that Square represents a square (with a width). Rectangle represents a rectangle (with a width and a height). an Snape derines an interface for shapes in general, providing a pure virtual member function area for computing the area of a shape. Design a suitable inheritance hierarchy that expresses: Squares and rectangles are shapes. and a square is a special kind of a rectangle, Implement the classes such that each class provides a reasonable constructor and implements the area function. Use double for representing widths and heights. Show transcribed image text Question # 4 (10 marks) Implement three classes Shape, Square, and Rectangle, such that Square represents a square (with a width). Rectangle represents a rectangle (with a width and a height). an Snape derines an interface for shapes in general, providing a pure virtual member function area for computing the area of a shape. Design a suitable inheritance hierarchy that expresses: Squares and rectangles are shapes. and a square is a special kind of a rectangle, Implement the classes such that each class provides a reasonable constructor and implements the area function. Use double for representing widths and heights.

Expert Answer


Answer to Question # 4 (10 marks) Implement three classes Shape, Square, and Rectangle, such that Square represents a square (with…

OR