【发布时间】:2009-09-26 02:38:20
【问题描述】:
我对优先队列的定义是:
template<typename Node, typename Cmp = std::less<Node> >
struct deref_compare : std::binary_function<Node*,Node*,bool>
{
deref_compare(Cmp const& cmp = Cmp())
: cmp(cmp) {}
bool operator()(Node* a, Node* b) const {
return (a->getfValue()> b->getfValue());
}
private:
Cmp cmp;
};
typedef deref_compare<Node,std::greater<Node> > my_comparator_t;
priority_queue<Node*,vector<Node*>,my_comparator_t> openq;
我在做:
openq.push(myNode)
进入 3-4 个节点后,出现分段错误。
mynode 不为空。
我该如何解决?
【问题讨论】:
-
您的代码 sn-p 非常混乱。尝试解决这个问题,我们会看到我们能为您做些什么。
标签: c++ templates segmentation-fault