#include
#include
#include
using namespace std;
const int inf=0x3f3f3f3f;
int T,N;
int B[1006];
int d[1006];
struct node{
int v;
int edge;
node(int _v,int _e):v(_v),edge(_e){}
};
vectorG[1006];
struct No{
int d,num;
bool operator < (const No& ret) const{
return d>ret.d;
}
};
//......
请问这段代码中的
bool operator < (const No& ret) const{
return d>ret.d;
}
是什么意思?
相当于重载了< 符号,对当前No变量A为例,输入另一个No变量B,比较AB的d值。常规来说如果的确A.d<B.d,那就返回true即真的小于,否则false。但这里是重新定义了只有当A.d>B.d时,才是真的小于。相当于给<符号定义了相反的意义