Assume I have a base class Shape, and a derived class from Shape, Triangle, defined in a project X in Visual Studio. I also have a class Transformations in a project Y in which I want to be able to call dynamically the appropriate method:
void Rotate(Shape& shape);
void Rotate(Triangle& triangle);
I'm trying to do this using a visitor pattern following this.
In both Shape.cpp and Triangle.cpp, I implemented to following method:
void rotate(Transformations trans) {
trans.Rotate(this);
}
However, project X is compiled before project Y, and project Y depends on project X, which leaves me with circular dependencies.
Unfortunately, forward declaring the Transformations class is not enough, as the knowledge of its member functions is necessary.
The answers provided in this thread did not help in that regard.