bool operator < (const node &a,const node &b) {
return a.id > b.id;
}
加引用是为了防止对象之间的复制,节省内存开销,提高程序运行效率。
加const是为了不让被调用函数改变传递给它的参数的对象的值。
并且加上const会使得函数调用更灵活(能够处理const和非const对象,否则只能接受非const数据)
const bool operator < (node &a,node &b) {
return a.id > b.id;
}
这种一般是返回的指针或者是引用,加const是规定返回值不可被修改
bool operator < (node &a,node &b) const{
return a.id > b.id;
}
这个函数不能访问类中所有this所能调用的内存,即这是个只读函数