求问重载"<"方法
查看原帖
求问重载"<"方法
47911
xiaozhangma楼主2023/11/16 15:48

题解里都是这样写的:

struct Info{
	int dis;
	int pos;
	bool operator <(const Info &x)const{
		return x.dis < dis;
	}
};

蓝书上则是这样:

struct Info{
	int dis;
	int pos;
};
bool operator <(const Info &x, const Info &y){
	return x.dis < y.dis;
}

但用蓝书上的写法会出错:(

2023/11/16 15:48
加载中...