小编byl*_*gja的帖子

将矢量填充到地图中

我试图用点矢量填充点地图.我试图制作棋盘游戏,棋盘上的每个位置都有一个点(x,y)和合法移动的矢量(Point对象).

我似乎无法将地图KEY作为Point.

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);
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误

在成员函数'bool std :: less <_Tp> :: operator()(const _Tp&,const _Tp&)const [with _Tp = Point]':

实例化自'_Tp&std :: map <_Key,_Tp,_Compare,_Alloc> :: operator [](const _Key&)[with _Key = Point,_Tp = std :: vector,std :: allocator>,std :: allocator, std :: allocator >>>,_Compare = std :: …

c++ stl map

0
推荐指数
2
解决办法
359
查看次数

标签 统计

c++ ×1

map ×1

stl ×1