Salut
J'ai besoin d'utiliser une table de hachage dans un programme mais lorsque je prend une cle de type string, il y a une erreur... (ca fonctionne avec une cle int ou float). Je comprend vraiment pas d'ou ca vien... Vla le code de test et l'erreur (j'utilise VC++ 7) :
------------------------------------------------------------------
#include <iostream>
#include <hash_map>
#include <string>
//typedef std::hash_map<int, float> HTable;
typedef std::hash_map<std::string, float> HTable;
HTable hTable;
int main()
{
using namespace std;
//int key;
std::string key;
float value;
cout<<"key"<<endl;
cin>>key;
cout<<"value"<<endl;
cin>>value;
hTable[key]=value;
cin>>key;
HTable::const_iterator place(hTable.find(key));
if(place !=hTable.end()){
cout<<key<<" : "<<place->second<<endl;
}else{
cout<<key<<" unknow."<<endl;
}
system("pause");
return 0;
}
------------------------------------------------------------------
ERREUR :
------------------------------------------------------------------
c:\Programmes\Microsoft Visual Studio .NET\Vc7\include\xhash(38): error C2440: 'type cast' : cannot convert from 'const std::string' to 'size_t'
------------------------------------------------------------------
Si quelqu'un a une idee pour resoudre ce probleme...