各位大佬们,小弟有个字典树里指针调用的问题望赐教!
关于字典树的一个疑问,为什么总是在p->child[pos]=NULL上报错读取访问权限冲突?void insert_I(TrieTreeNode* p, const string& word)
{
for (int i = 0; i < word.length(); ++i)
{
int pos = word[i] - 'a';
if (p->child[pos] == NULL)
{
p->child[pos] = new TrieTreeNode();
p->child[pos]->ch = word[i];
p->child[pos]->parent = p;
}
p->child[pos]->PrefixCount++;
p = p->child[pos];
}
p->WordCount++;
}