我很难让我的优先级队列识别它应该排序的参数。我在自定义类中重载了小于运算符,但它似乎没有使用它。以下是相关代码:
节点.h
class Node
{
public:
Node(...);
~Node();
bool operator<(Node &aNode);
...
}
节点.cpp
#include "Node.h"
bool Node::operator<(Node &aNode)
{
return (this->getTotalCost() < aNode.getTotalCost());
}
getTotalCost() 返回一个整数
主文件
priority_queue<Node*, vector<Node*>,less<vector<Node*>::value_type> > nodesToCheck;
我错过了什么和/或做错了什么?