A square — a special case of Rectangle where width equals height. More...
#include <shapes.hpp>
Public Member Functions | |
| Square (double side) | |
| Construct a square with the given side length. | |
| std::string | name () const override |
| Return the human-readable name of the shape. | |
| double | side () const |
| Get the side length. | |
Public Member Functions inherited from geometry::Rectangle | |
| Rectangle (double width, double height) | |
| Construct a rectangle. | |
| double | area () const override |
| Compute the area of the shape. | |
| double | height () const |
| Get the height. | |
| double | perimeter () const override |
| Compute the perimeter of the shape. | |
| double | width () const |
| Get the width. | |
Public Member Functions inherited from geometry::Shape | |
| virtual | ~Shape ()=default |
| Virtual destructor for safe polymorphic deletion. | |
| std::string | describe () const |
| Pretty-print shape information. | |
Additional Inherited Members | |
Static Public Member Functions inherited from geometry::Shape | |
| static int | instance_count () |
| Get the total count of Shape instances created. | |
Protected Member Functions inherited from geometry::Shape | |
| Shape () | |
| Increment the instance counter. | |
Protected Attributes inherited from geometry::Rectangle | |
| double | height_ |
| The rectangle's height. | |
| double | width_ |
| The rectangle's width. | |
A square — a special case of Rectangle where width equals height.
\[ A = s^2, \qquad P = 4s \]
name(). It demonstrates a deeper inheritance chain for the class diagram. Definition at line 177 of file shapes.hpp.
|
inlineexplicit |
Construct a square with the given side length.
| side | The side length (must be positive). |
Definition at line 183 of file shapes.hpp.
References geometry::Rectangle::Rectangle(), and side().
|
inlinenodiscardoverridevirtual |
Return the human-readable name of the shape.
"Circle", "Rectangle", etc. Reimplemented from geometry::Rectangle.
Definition at line 185 of file shapes.hpp.
|
inlinenodiscard |
Get the side length.
Definition at line 188 of file shapes.hpp.
References geometry::Rectangle::width_.
Referenced by Square().