I'm new to OOP and data structures. I'm playing around with a C++ algorithm to compare one string sentence with another. The idea is to extract individual words from both strings, store them in two different hash tables and determine with a boolean if the words of the first string appear in the second one. There must be many ways to solve this, but for my purposes the approach should use hash tables. I created a class called hashClass which has one constructor and three methods. The first method splits the string, the second hashes the words split and stores them at an index in the hash table and the third method should determine if the words of the first string (Magazine object) appear in the second one (Note object) have. I'm stuck at the third mainly because I don't know how to compare the contents stored at the hash tables in each object. Here is the code for my main.cpp:
int main()
{
hashClass Magazine;
hashClass Note;
Magazine.SplitString("give me one grand today night");
Note.SplitString("igev em eno drnag today night");
bool IsMagReplica(const hashClass Magazine, const hashClass Note)
{
//what can I do here to compare the contents of both hash tables which are stored as objects of a class?
}
return 0;
}
Here is the code for my hash.h:
class hashClass
{
public:
hashClass();
void SplitString(string str);
int HashWord(string word, int length);
bool IsMagReplica(hashClass htMag, hashClass htNote);
private:
static const int tableSize = 52;
struct item
{
string word;
int length;
item* next;
};
item* HashTable[tableSize];
};
Let me know if you also need to take a look at the hash.cpp code. Any help is deeply appreciated. Hope my explanation is clear and concise. Thanks.