【发布时间】:2012-09-23 00:58:42
【问题描述】:
我正在尝试将对存储在优先级队列中,并且我正在使用比较函数来比较每对的第二个值。
#include<iostream>
#include<queue>
#include<utility>
using namespace std;
class CompareDist
{
public:
bool operator()(pair<int,int> n1,pair<int,int> n2) {
return n1.second>n2.second;
}
};
int main()
{
priority_queue<pair<int,int>,CompareDist> pq;
}
编译时出现错误
error: no type named ‘value_type’ in ‘class CompareDist’
可能是什么原因。我是 STL 新手。
【问题讨论】:
标签: c++ stl priority-queue std-pair