class Trie {
private:
vector<Trie*> children;
bool isEnd;
Trie* searchPrefix(string prefix) {
Trie* node = this;
for (char ch : prefix) {
ch -= 'a';
if (node->children[ch] == nullptr) {
return nullptr;
}
node = node->children[ch];
}
return node;
}
}
Why can the Trie* type appear first in a Trie class definition. The Trie type has not yet been defined.How does the compiler know what Trie* is?
I tried looking online for an answer, but couldn't find it. I think it is a certain knowledge of mine that I have not figured out. Please help me and guide me. Thanks!