Abstract base class for all 2D shapes. More...
#include <shapes.hpp>
Public Member Functions | |
| virtual | ~Shape ()=default |
| Virtual destructor for safe polymorphic deletion. | |
| virtual double | area () const =0 |
| Compute the area of the shape. | |
| std::string | describe () const |
| Pretty-print shape information. | |
| virtual std::string | name () const =0 |
| Return the human-readable name of the shape. | |
| virtual double | perimeter () const =0 |
| Compute the perimeter of the shape. | |
Static Public Member Functions | |
| static int | instance_count () |
| Get the total count of Shape instances created. | |
Protected Member Functions | |
| Shape () | |
| Increment the instance counter. | |
Abstract base class for all 2D shapes.
Every shape must provide its area, perimeter, and a human-readable name. The Shape class also tracks the total number of shape instances created (demonstrating static member documentation).
std::unique_ptr<Shape> for polymorphic ownership.Definition at line 47 of file shapes.hpp.
|
virtualdefault |
Virtual destructor for safe polymorphic deletion.
|
inlineprotected |
|
nodiscardpure virtual |
Compute the area of the shape.
Implemented in geometry::Circle, geometry::Rectangle, and geometry::Triangle.
Referenced by describe().
|
inlinenodiscard |
Pretty-print shape information.
"ShapeName(area=..., perimeter=...)". Definition at line 74 of file shapes.hpp.
References area(), name(), and perimeter().
|
inlinestatic |
Get the total count of Shape instances created.
Definition at line 83 of file shapes.hpp.
|
nodiscardpure virtual |
Return the human-readable name of the shape.
"Circle", "Rectangle", etc. Implemented in geometry::Circle, geometry::Rectangle, geometry::Square, and geometry::Triangle.
Referenced by describe().
|
nodiscardpure virtual |
Compute the perimeter of the shape.
Implemented in geometry::Circle, geometry::Rectangle, and geometry::Triangle.
Referenced by describe().