为什么我的程序使用STL映射在键已存在时插入值而不是更改现有值?
#include <iostream>
#include <map>
using namespace std;
struct CTest
{
int a, b, c;
CTest(int A, int B, int C) : a(A), b(B), c(C) {}
};
bool operator<(const CTest & l, const CTest & r)
{
if(l.a < r.a) return true;
else if(l.a > r.a) return false;
if(l.b < r.b) return true;
else if(l.b > r.b) return false;
if(l.c < r.c) return true;
else if(l.c > r.c) return false;
return true;
}
struct CTest2
{
bool operator<(const CTest2 & …Run Code Online (Sandbox Code Playgroud)