Hash map error: no match for call to ‘(const __gnu_cxx::

Hash map error: no match for call to ‘(const __gnu_cxx::

在编译我的 hash_multimap 之后,我得到了一个很大的段落错误 在成员函数‘size_t__gnu_cxx::hashtable<

我从来没有见过这么大的错误,而且由于它的大小异常,我实际上不确定如何解决这个错误。

为什么行的任何建议:

p = map1.equal_range(searchKey);

导致这个异常长的错误?仅供参考-我删除了整个错误并删除了中间部分,因为一旦我将它粘贴到这里,它就像一页长 O.o

错误

/usr/include/c++/4.3/backward/hashtable.h: In member function ‘size_t
__gnu_cxx::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey,  
_Alloc>::_M_bkt_num_key(const _Key&, size_t) const [with _Val = 
std::pair<const std::basic_string<char, std::char_traits<char>, 
std::allocator<char> >, Map2*>, _Key = std::basic_string<char 

...

std::char_traits<char>, std::allocator<char> > >, _Alloc =     
std::allocator<Map2*>]’
hash_map2.cpp:55:   instantiated from here
/usr/include/c++/4.3/backward/hashtable.h:595: error: no match for call to  
‘(const __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>,   
std::allocator<char> > >) (const std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >&)’

Map.h 文件

#ifndef MAP2_H
#define MAP2_H

#include <iostream>
#include <string>

using namespace std;

class Map2 {

public:
Map2(string data1, string data2, string data3, string data4, string data5);
string pop, keyword, user, desc, id;

string get_pop() {return pop;}
string get_key() {return keyword;}
string get_user() {return user;}
string get_desc() {return desc;}
string get_id() {return id;}

void call_Values(int i); 

};

Map2:: Map2(string data1, string data2, string data3, string data4, string data5) {
    pop = data1;
    keyword = data2;
    user = data3;
    desc = data4;
    id = data5;
}

void Map2:: call_Values(int i) {

    get_pop();
    get_key();
    get_user();
    get_desc();
    get_id();
}

#endif

hash_map2.cpp

#include <fstream>
#include <iostream>
#include "Map2.h"
#include <ext/hash_map>
#include <string>
#include <sstream>

using namespace std;
using __gnu_cxx::hash_multimap;

    int nav() {
            cout <<"Select from the following options : " << endl <<endl;
            cout <<"Search Tweets based on Keyword (Type 1) " <<endl;
            cout <<"End Program (Type 2)"<<endl<<endl;
            int key =0;
            cin >> key;
            return key;
    }

int main() {

int option = nav();

if (option == 1) {
    ifstream readFile("project4.csv");
    string tempPop, tempID, tempKey, tempUser, tempDesc;
    string tempRead;

    hash_multimap<string, Map2 *>map1;

    while (readFile != NULL){
        // sends to a temp variable
        readFile >> tempRead;

        for (int i =0; i<400; i++){
    //create new object each time
            Map2 *mapNode = new Map2(tempPop,tempID,tempKey,tempUser,tempDesc);
    //insert each time new object is made
    map1.insert(pair<string, Map2 *> (tempKey, mapNode));

        } //end for
    } //end while


//Navigation through multimap
    //first pointer is for first one and second to last hash table value
    pair<hash_multimap<string, Map2 *> :: const_iterator,
            hash_multimap<string, Map2 *> :: const_iterator> p;

    string searchKey = "";
    cout << "Please enter the keyword value exactly so we can search the"<< 
    "available tweets: " <<endl;

    cin >> searchKey;
    p = map1.equal_range(searchKey);







}

else

return 0;
}

问题是调用字符串进行搜索。在调用 equal_range 函数内部的值之前需要将字符串转换为 int。