One idea is to move your Comparator definitions to a .cpp source while keeping the declarations in the header. This way, restaurant.h
and recipe.h
will still only refer to each other by name and so a forward declare will still be enough.
// restaurant_recipe_comparators.h
// probably too long, give it a better name
struct RestaurantComparator
{
bool operator() (const Restaurant *, const Restaurant *);
};
struct RecipeComparator
{
bool operator() (const Recipe *, const Recipe *);
};
// restaurant_recipe_comparators.cpp
bool RestaurantComparator::operator() (const Restaurant* lhs, const Restaurant* rhs)
{
return lhs->averagePrice() < rhs->averagePrice();
}
bool RecipeComparator::operator() (const Recipe* lhs, const Recipe* rhs)
{
return lhs->price() < rhs->price();
}