Hi Gurus!!
Thanks in advance.
I need to construct a hash table, I use STL hash_map template but I have some errors. I am using Visual Studio 2003 and it is my code:
Code:#include <hash_map> #include <vector> struct eqstr { bool operator()(char* s1, char* s2) { return strcmp(s1, s2) == 0; } }; class CSimplificada { public: BOOL nTipo; // 0 S1 1 S2 char sKey[256]; vector <int> vnPosInFile; CSimplificada() { sKey[0] = '\0'; nTipo = -1; vnPosInFile.clear(); } const CSimplificada & operator = (const CSimplificada &s) { strcpy(sKey, s.sKey); nTipo = s.nTipo; vnPosInFile = s.vnPosInFile; return *this; } bool operator < (const CSimplificada &s) { if(strcmp(sKey, s.sKey) < 0) return true; return false; } bool operator == (const CSimplificada &s) { if(strcmp(sKey, s.sKey) == 0 && nTipo == s.nTipo) return true; return false; } };
When I try to declare hash_map, for example:
I get compiler errors. Is right the code? what is happening?Code:hash_map <char *,CSimplificada,hash_compare <char*>, eqstr> hashMapS1;
Very thanks!!!




Reply With Quote