std::map < type_1,type_2 > data;
type_1有什么要求?
为什么我自定义了一个类,重载了<操作符,编译时没有错误,运行去出错了。
出错代码如下;
std::vector > record_number;
//
std::vector arr = record_number[input_po];
if (arr.size() > 4) {
return;
}
else {
arr.push_back(number[0] - '0');
record_number[input_po] = arr; //运行到这行出错
}
Position 定义如下
class Position{
public:
int x;
int y;
Position(int a ,int b):x(a),y(b){}
Position():x(1),y(1){}
bool operator <(const Position & po) const
{
if (x < po.x) {
return true;
}
else if (x == po.x) {
if (y < po.y) {
return false;
}
}else {
return false;
}
}
};