【发布时间】:2016-07-16 05:08:58
【问题描述】:
以下代码是我正在制作的国际象棋游戏的一部分,其中关键是棋子的位置,值是棋子可能的移动
#include<iostream>
#include<map>
#include<vector>
using namespace std;
struct Coordinate{
int x, y;
};
int main(){
map<Coordinate, vector<Coordinate>> moves;//map that have an struct as key and a vector of structs as value.
//There is the error
moves.insert(make_pair(Coordinate{0,0},//the struct
vector<Coordinate>{Coordinate{1,1},//the vector
Coordinate{2,2},
Coordinate{3,3}}));
return 0;
};
这些代码将我带到文件 'stl_function.h' 中的第 235 行
【问题讨论】:
-
>在哪里?您还需要一个自定义比较器或Coordinate上的operator<。 -
是的
Vector<在第 15 行打开但没有关闭... -
包含您遇到的错误。
-
如果你使用
[],它可能是可读的 -
movements[ {0,0} ] = { {1,1}, {2,2}, {3,3} };也是如此