【发布时间】:2013-01-25 02:04:30
【问题描述】:
我关注http://www.cplusplus.com/reference/map/map/map/。
我正在尝试构建一个反向索引结构,它是一个以 64 位整数作为键的映射,每个键都将保存一个指向子映射的指针。子映射将包含 int int 对。所以我让自己写了一些示例:
map<unsigned long long int, map<int, int>*> invertID;
int main(int argc, char *argv[]){
map<int,int>* m = new map<int,int>();
m[10] = 1;
invertID[1] = m;
return 0;
}
但是对于像这样的非指针类型的映射来说,这通常是个问题
std::map<char,int> first;
如http://www.cplusplus.com/reference/map/map/map/中所述,我知道我们可以做到
first['a']= 10;
但是如果我们有一个map的指针类型,我们该怎么做呢?我上面的代码会产生一个错误提示
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
【问题讨论】: