Skip to content

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

Open

Description

@akkul143

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:

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:

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions