これらは、2 つのクラスを宣言する 2 つの C++ ヘッダー ファイル内のコードです。一方は他方のフレンドです。
==>最初のクラスは、ハッシュ テーブルを作成し、与えられたファイルから単語を入力します。
#include "remove_duplicates.h"
class Hash_class{
protected:
list<string> *hashTable;
string input_file;
string output_file;
int input_file_size;
friend class remove_duplicates;
//void file_size();
public:
/*load the words in the hash Table;
by calculating the hash Code of each string*/
Hash_class(string input_file,string output_file="output_file.txt");
~Hash_class(){
fclose(input_file);
fclose(ouput_file);
}
int hashCode( const string input_word);
void loadInHash();
void write_in_output();
int get_input_file_size(){
return input_file_size;
}
string get_input_file(){
return input_file;
}
string get_output_file(){
return output_file;
}
};
2 番目のクラスでは、最初のクラスからオブジェクトを作成し、最初に作成したオブジェクト内のハッシュ テーブルを埋めてから、重複と見なされるすべての単語を削除することによって、最初のクラスからオブジェクトを作成し、それに基づいて操作したいと考えました (レーベンシュタイン距離が特定の比率に近い場合)。 .
#include "Hash_class.h"
class remove_duplicates{
protected:
Hash_class hash_object;
public:
remove_duplicates(Hash_class & hash_object);
int Levenshtein_distance(string s1,string s2);
void set_purge();
};
問題は、コードをコンパイルするとエラーが発生することです: ([Error] 'Hash_class' does not name a type) 可能であれば、方法またはそれについて学べるソースを教えてください。それが不可能な場合は、いくつかのヒントが役立ちます。
(「GCC 4.3.2 を使用しています」)