您的位置:首页 > 产品设计 > UI/UE

priority_queue|instantiated

2014-05-14 20:56 267 查看
关于 instantiated from here

struct node{
int x, y;
node(int a = 0, int b = 0) {
x = a;
y = b;
}
};

int main() {
int i, j, k, n, m, t, time;
node temp, nod;
cin >> k;
while (k--) {
time = 0;
priority_queue<node> pri_q;  //出错 instantiated from here
queue<node> q;
……
}
……
}


出错原因:对于自定义类型,则必须自己重载 operator< 或者自己写仿函数:

bool operator<( node a, node b ) {
return a.x < b.x;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息