C++ 类中的静态函数给出错误:声明

C++ 类中的静态函数给出错误:声明,c++,class,sorting,compare,C++,Class,Sorting,Compare,我尝试使用自定义比较函数,并在排序和堆中使用它。现在,类节点使用operatir我不知道这是否就是您测试的代码,但是我看到了另一个错误,编译器会抱怨。在: static bool Cmpr(Node a, Node b){ return a->dist > b->dist; } 可以将节点a和b视为指针,但它们不是指针。如果我将此更改为: static bool Cmpr(Node a, Node b){ return a.dist > b.dist;


我尝试使用自定义比较函数,并在排序和堆中使用它。现在,类节点使用operatir我不知道这是否就是您测试的代码,但是我看到了另一个错误,编译器会抱怨。在:

static bool Cmpr(Node a, Node b){
    return a->dist > b->dist;
}
可以将节点a和b视为指针,但它们不是指针。如果我将此更改为:

static bool Cmpr(Node a, Node b){
    return a.dist > b.dist;
}

编译时我没有收到任何错误。

s/
static bool Cmpr(节点a,节点b){
/
static bool Cmpr(节点*a,节点*b){
啊,感恩的塞德。哈雷和他的彗星经典awk的粉丝。谢谢,斯雷!你说得对!我改变了很多代码,以检查这是否解决了我的问题。但忘了恢复它!我在本地机器上检查并编译,没有错误!只有在尝试代码战时才得到错误!显然,它有问题一般的静态方法!!!
static bool Cmpr(Node a, Node b){
    return a->dist > b->dist;
}
static bool Cmpr(Node a, Node b){
    return a.dist > b.dist;
}