为了备考,看了管理员阮行止的旧课
其中有一课,说unordered_set不能用结构体
可经测试,可以用结构体呀
测试代码如下↓
#include<iostream>
#include<cstring>
#include<unordered_set>
using namespace std;
int sum;
struct student{
char name[70];
int level;
int id=++sum;
bool operator==(const student& a) const{
return !(strcmp(a.name,name)) && level == a.level;
}
};
struct test_hash{
int hash(student o){
return o.id;
}
};
int main(){
unordered_set<student,test_hash> our_class;
return 0;
}