여기서 잘못된 점을 파악할 수 없습니다.
목록을 정렬하고이를 비교하는 비교 기능이 필요합니다.
정확하게 내 문제가 해결되었지만 나에게 적합하지 않은 코드 예제를 찾았습니다.
오류 :하지 셀 내 타입은 ISO C++이없는 유형C++에서 ... 구조체를 함수에 전달하는 동안 형식 오류가 발생하지 않습니다.
와 '셀'의 선언을 금지인가
난 항상이 오류가?
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;
}