Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 哈希映射错误:对‘;(常数gnu cxx::_C++_Object_Compiler Errors_Hashmap - Fatal编程技术网

C++ 哈希映射错误:对‘;(常数gnu cxx::

C++ 哈希映射错误:对‘;(常数gnu cxx::,c++,object,compiler-errors,hashmap,C++,Object,Compiler Errors,Hashmap,编译hash_multimap后,我的 在成员函数“size\u t\u gnu\u cxx::hashtable”中 pI从未见过这个巨大的错误,实际上我不确定如何修复这个错误,因为它的大小不正常。/p 公司建议为什么行:/p pis导致了这个异常长的错误?仅供参考-我剪切了整个错误并删除了中间部分,因为一旦我将其粘贴到这里,它就像一页长的O.O/p 佩罗尔/p precode/usr/include/c++/4.3/backward/hashtable.h:成员函数中的“size\t” __

编译hash_multimap后,我的 在成员函数“size\u t\u gnu\u cxx::hashtable”中 pI从未见过这个巨大的错误,实际上我不确定如何修复这个错误,因为它的大小不正常。/p 公司建议为什么行:/p pis导致了这个异常长的错误?仅供参考-我剪切了整个错误并删除了中间部分,因为一旦我将其粘贴到这里,它就像一页长的O.O/p 佩罗尔/p precode/usr/include/c++/4.3/backward/hashtable.h:成员函数中的“size\t” __gnu_cxx::hashtable_Val、_Key、_HashFcn、_ExtractKey、_EqualKey、, _Alloc::_M_bkt_num_key(常数_key&,大小_t)常数[带_Val= std::pairconst std::basic_stringchar,std::char_traitschar, std::allocatorchar,Map2*,_Key=std::basic_stringchar /编码/预编码 p、 ../p 预目的地::char\u traitschar,std::allocatorchar>,\u Alloc= std::分配器]' hash_map2.cpp:55:从此处实例化 /usr/include/c++/4.3/backward/hashtable.h:595:错误:调用 “(常量gnu cxx::散列)(常量std::基本字符串&)” 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
\ifndef MAP2\u H
#定义MAP2_H
#包括
#包括
使用名称空间std;
类映射2{
公众:
Map2(字符串数据1、字符串数据2、字符串数据3、字符串数据4、字符串数据5);
字符串pop、关键字、用户、描述、id;
字符串get_pop(){return pop;}
字符串get_key(){return关键字;}
字符串get_user(){return user;}
字符串get_desc(){return desc;}
字符串get_id(){return id;}
无效调用_值(int i);
};
Map2::Map2(字符串data1、字符串data2、字符串data3、字符串data4、字符串data5){
pop=数据1;
关键词=数据2;
用户=数据3;
desc=数据4;
id=数据5;
}
void Map2::调用_值(int i){
获得流行音乐();
获取密钥();
获取用户();
获取_desc();
get_id();
}
#恩迪夫
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;
}
#包括
#包括
#包括“Map2.h”
#包括
#包括
#包括
使用名称空间std;
使用_gnu_cxx::hash_multimap;
国际导航(){

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

如果您可以访问C++11,请删除
\uuu gnu cxx::hash_multimap
并将其替换为
std::unordered_multimap
from
/code>@Cyber中的
EVE我的版本不是C++11@Cyber无序映射不适用于我的版本
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> >&)’
#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
#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;
}