在 Student 结构体中,重载运算符 < 与 >
struct Student{
string name;
int score;
// 第一个const表明 结构体t的值不会改变
// 第二个const表明 结构体this的值不会改变
bool operator < (const Student& t) const{
return score < t.score;
}
bool operator > (const Student& t) const{
return score > t.score;
}
}a[N];