【发布时间】:2012-01-28 23:10:04
【问题描述】:
我在 Ubuntu 中使用 GCC 定义了一个 hash_map
当我打电话时
string a = "sgsg";
string temp = stringHash[a];
编译器报告以下错误:
错误:传递 'const __gnu_cxx::hash_map, std::basic_string, StringHashFunctionStruct>' 作为 '_Tp& __gnu_cxx::hash_map<_key _tp _hashfn _equalkey _alloc>::operator[]( const key_type&) [with _Key = std::basic_string, _Tp = std::basic_string, _HashFn = StringHashFunctionStruct, _EqualKey = std::equal_to >, _Alloc = std::allocator >, __gnu_cxx::hash_map<_key _tp _hashfn _equalkey _alloc>::key_type = std::basic_string]' 丢弃限定符 [-fpermissive]
为什么会发生这种情况?我应该如何使用字符串到字符串 hashMap?
【问题讨论】: