ここで何が間違っているのかわかりません。
リストをソートし、それをソートするための比較機能が必要です。
私の問題が正確に解決されたコード例を見つけましたが、うまくいきません。
私はいつもこのエラーを受け取ります:
エラー: ISO C++ は型のない 'Cell' の宣言を禁止しています
セルは私のタイプで はありませんか?
AStarPlanner.h
class AStarPlanner {
public:
AStarPlanner();
virtual ~AStarPlanner();
protected:
bool compare(const Cell& first, const Cell& second);
struct Cell {
int x_;
int y_;
int f_; // f = g + h
int g_; // g = cost so far
int h_; // h = predicted extra cost
Cell(int x, int y, int g, int h) : x_(x), y_(y), g_(g), h_(h) {
f_ = g_ + h_;
}
};
};
AStarPlanner.cpp
bool AStarPlanner::compare(const Cell& first, const Cell& second)
{
if (first.f_ < second.f_)
return true;
else
return false;
}