我想使用 STL 中的一对作为地图的键。
#include <iostream>
#include <map>
using namespace std;
int main() {
typedef pair<char*, int> Key;
typedef map< Key , char*> Mapa;
Key p1 ("Apple", 45);
Key p2 ("Berry", 20);
Mapa mapa;
mapa.insert(p1, "Manzana");
mapa.insert(p2, "Arandano");
return 0;
}
但是编译器会抛出一堆不可读的信息,而且我对 C 和 C++ 很陌生。
如何在地图中使用一对作为键?一般来说,我如何使用任何类型的结构(对象、结构等)作为地图中的键?
谢谢!