괜찮 았어.이 코드는 정말 쉽지만,이 코드는 부스트 라이브러리를 구현하고있다. 올바르게 작동하도록하는 것 같습니다. 여기에 코드가 있습니다.부스트 라이브러리, C++로 정렬되지 않은 세트는 나에게 두통을 준다.
#include .....
#include "boost/unordered_set.hpp"
#ifndef HASH_H
#define HASH_H
class hash{
public:
int toHash(string);
void insertKey(string);
bool lookupKey(string);
private:
string hashTable[];
vector<string> vfile;
typedef boost::unordered_set<std::string, int> um;
struct hashkey{
string state;
int stateno;
};
};
#endif /* HASH_H */
hash.h 또한 hash.cpp
#include <boost/unordered/unordered_set.hpp>
#include "hash.h"
int hash::toHash(string key){
unsigned int x;
std::stringstream ss;
ss << std::hex << key;
ss >> x;
return x;
}
void hash::insertKey(string key){
um.insert(key,toHash(key));
}
bool hash::lookupKey(string key){
return um.find(key)==um.end();
}
나는군요 "hash.cpp : '.'토큰 전에 예상 비정규-ID 18 : 7 : 오류". 그리고 저는 다시 한 번 강조해 보았습니다. 아마도 꽤 쉽다는 것을 알고 있습니다. 인터네트에서 많은 예제를 살펴 봤는데이 "단순한"작품을 얻는 것만으로는 부족합니다. 감사합니다.
Nitpicking하지만 헤더에 전체 파일을 감싸 야합니다. 그렇지 않으면 동일한 파일을 여러 번 포함 할 수 있습니다 (적절한 헤더 포함 경비가없는 경우). –