구조체가있는 클래스와이 구조체가있는 목록이 있습니다.
하지만이 목록을 반복 할 때 속성을 구조체에서 가져올 수 없습니다.목록을 반복하는 동안 내 구조체의 속성을 가져올 수 없습니다.
오류 : 부재 'X_'에 대한 요구가 '_Tp = AStarPlanner와 it.std :: _ List_const_iterator < _Tp> :: * 연산자 :: 셀 *', 'AStarPlanner :: 셀이 아닌 클래스 타입 인 * const를 '
헤더 파일 :
class AStarPlanner {
public:
AStarPlanner(int width, int height, const costmap_2d::Costmap2D* costmap);
virtual ~AStarPlanner();
protected:
struct Cell {
int x_;
int y_;
int f_; // f = g + h
int g_; // g = cost so far
int h_; // h = predicted extra cost
//CellInfo* visited_from_; // pointer to cell from which this cell is visited
Cell(int x, int y, int g, int h) : x_(x), y_(y), g_(g), h_(h) {
f_ = g_ + h_;
}
};
bool cellInList(const Cell* cell, const std::list<Cell*> liste);
};
CPP 파일 :
bool AStarPlanner::cellInList(const Cell* cell, const list<Cell*> liste)
{
list<Cell*>::const_iterator it;
for (it = liste.begin(); it != liste.end(); it++)
{
if (it->x_ == cell->x_ && it->y_ == cell->y_)
return true;
}
return false;
}
귀하의 초기 주장은 명백한 거짓이다 : 당신은 구조체의 목록이 아니라 * 포인터의 목록이 없습니다 *. –