c++ code errors, need help…
SPONSORED LINKS
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
class TrieNode
{
private:
char data;
bool isWord;
TrieNode childNodes;
public:
TrieNode()
{
}
TrieNode(char argData)
{
data = argData;
isWord = false;
}
void setIsWord(bool thisIsWord)
{
isWord = thisIsWord;
}
int getCharInt(char argChar)
{
return int(argChar) – int(‘a’);
}
TrieNode *Search(char argChar)
{
return childNodes[getCharInt(argChar)];
}
void Insert(string argString)
{
if (Search(argString.at(0)) == NULL)
{
TrieNode *temp = new TrieNode(argString.at(0));
childNodes[getCharInt(argString.at(0))] = temp;
}
if (argString.length() > 1)
{
childNodes[getCharInt(argString.at(0))]->Insert(argString.substr(1));
}
else
{
childNodes[getCharInt(argString.at(0))]->setIsWord(true);
}
}
};
i keep getting errors like:
field childNodes has incomplete type
in member Search, childNodes undefined (first use this function)
in member Insert, childNodes undefined (first use this function)
i would guess that the error rests with something about the childNodes field, but i have no clue to to what.
thanks for any and all help with this.
See the original post:
c++ code errors, need help…