我試圖使用點矢量填充點圖。我正在嘗試做一個棋盤遊戲,棋盤上的每個位置都有一個點(x,y)和法律移動向量(點對象)。將填充矢量填充到地圖中
我似乎無法將地圖KEY作爲點。
struct Point
{
Point() {}
Point(int ix, int iy) :x(ix), y(iy) {}
int x;
int y;
};
Point p_source (2,2);
Point p_next1 (1,2);
Point p_next2 (1,3);
Point p_next3 (1,4);
map <Point, vector<Point> > m_point;
dict[p_source].push_back(p_next1);
dict[p_source].push_back(p_next2);
dict[p_source].push_back(p_next3);
這是錯誤的,我得到
In member function 'bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Point]':|
instantiated from '_Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = Point, _Tp = std::vector, std::allocator >, std::allocator, std::allocator > > >, _Compare = std::less, _Alloc = std::allocator, std::allocator >, std::allocator, |
instantiated from here|
c:\program files (no match for 'operator<' in '__x < __y'| ||=== Build finished: 1 errors, 0 warnings ===|
給答案是:好。解釋錯誤:無價。 – chris