【发布时间】:2017-12-10 04:15:03
【问题描述】:
我尝试使用自定义比较函数并在排序和堆中使用它。现在类节点使用operatir
class Node{
public:
int id;
int dist;
Node(int node_id, int fdist = -1):
id (node_id),
dist (fdist)
{};
bool operator<(const Node & other) const{
return dist > other.dist;
}
static bool Cmpr(Node a, Node b){
return a->dist > b->dist;
}
};
我总是收到以下错误:
file.cpp on line 14:36: error: two or more data types in declaration of 'Cmpr'
static bool Cmpr(Node a, Node b){
我的代码有什么问题?
【问题讨论】:
-
s/
static bool Cmpr(Node a, Node b){/static bool Cmpr(Node* a, Node* b){ -
啊,感恩的 sed。更喜欢哈雷和他的彗星经典 awk 全天候。