我不斷收到錯誤,沒有構造函數可以採取源類型或構造函數重載解決方案。沒有構造函數可以採取源類型
在我的代碼的開始,我宣佈了一個無序的地圖。
unordered_map<char * , a_dictionary * > Mymap;
unsigned char hash[20];
char hex_str[41];
string answer, line;
int yes=0;
cout<<"Press 1 if you would like to use the default file(d8.txt) or press 2 if you want your own file"<<endl;
getline(cin,answer);
stringstream(answer)>> yes;
if(yes == 1)
{
ifstream myfile("d8.txt");
if (myfile.is_open())
{
while (myfile.good())
{
getline (myfile,line);
//cout<<line<<endl;
a_dictionary * dic = new dictionary();
dic->word = line;
const char * c= line.c_str();
sha1::calc(c,line.length(), hash);
sha1::toHexString(hash,hex_str);
Mymap.insert(hex_str, dic); //
這條線就在這裏 「mymap.insert」 不斷給我的錯誤錯誤C2664:「的std :: _ List_iterator < _Mylist>的std :: _哈希< _Traits> ::插入(標準:: _ List_const_iterator < _Mylist> ,_Valty),即使我正確地傳遞正確的值?
這裏是調用toHeXString
void toHexString(const unsigned char* hash, char* hexstring)
{
const char hexDigits[] = { "abcdef" };
for (int hashByte = 20; --hashByte >= 0;)
{
hexstring[hashByte << 1] = hexDigits[(hash[hashByte] >> 4) & 0xf];
hexstring[(hashByte << 1) + 1] = hexDigits[hash[hashByte] & 0xf];
}
hexstring[40] = 0;
}
非常感謝。它做到了。 – user1665569 2013-02-27 01:27:54
@ user1665569不是問題,謝謝 – 2013-02-27 01:55:22