Visitor Pattern C++ example is missing accept() method implementations

Author: akkul143Created Aug 3, 2026Updated Aug 3, 2026

The C++ Visitor Pattern example declares the accept() methods in the Circle and Rectangle classes, but their implementations are missing.

Currently, both classes only contain:

cpp
void accept(ShapeVisitor* visitor) override;

This is only a method declaration. It does not automatically call visitCircle() or visitRectangle().

The methods should either be implemented directly inside their respective classes or defined outside the classes after the complete ShapeVisitor definition.

For example:

cpp
void Circle::accept(ShapeVisitor* visitor) {
    visitor->visitCircle(this);
}

void Rectangle::accept(ShapeVisitor* visitor) {
    visitor->visitRectangle(this);
}

Without these definitions, the provided code is incomplete and results in linker errors for Circle::accept() and Rectangle::accept().

Please add the missing implementations either directly inside the concrete shape classes or outside them after defining ShapeVisitor.

Source: ashishps1/awesome-low-level-design