2
我试图重写操作<如下所示:如何重写操作<
内部节点:
bool operator <(const Node* other) {
return *(this->GetData()) < *(other->GetData());
}
车内:
bool operator <(const Vehicle &other) {
return this->GetKilometersLeft() < other.GetKilometersLeft();
}
调用操作:
while (index > 0 && m_heapVector[index] < m_heapVector[parent(index)])
矢量定义:
vector<Node<T>*> m_heapVector;
我检查了通话,它没有调用覆盖的操作符。
打我给它。 “相应地调整运算符”的意思是'节点 ::运算符<()'应该把一个引用而不是一个指针指向'other'。 –
2010-09-19 16:29:37
@Ben没问题,固定运营商 – Anycorn 2010-09-19 16:32:33
@Roy,通知运营商应该是'(const Node&other)' – Anycorn 2010-09-19 16:55:35