求助unordered_map的结构体重载运算符
  • 板块灌水区
  • 楼主GHJhandsome
  • 当前回复3
  • 已保存回复3
  • 发布时间2021/11/25 20:14
  • 上次更新2023/11/3 23:35:13
查看原帖
求助unordered_map的结构体重载运算符
67820
GHJhandsome楼主2021/11/25 20:14

rt,不知道为什么没过编译,觉得是重载运算符的问题。

#include<unordered_map>
using namespace std;
struct gg{
	int x,y;
	operator <(const gg g)const{return x<g.x;}
	operator >(const gg g)const{return x>g.x;}
};
unordered_map<gg,int>mp;
int main(){
	mp[{1,2}]=3;
}
2021/11/25 20:14
加载中...