#ifndef TRIEAPI
#define TRIEAPI
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;
typedef struct NodeStruct
{
bool validNgram = false;
unordered_map<string, struct NodeStruct> children;
struct NodeStruct* parent;
string nodeWord;
NodeStruct(struct NodeStruct* par, string w) : parent(par), nodeWord(w) {} //constructor (yeah, structs have them too)
NodeStruct() {}
}Node;
void addNgramTrie(Node* root, string ngram);
void findNgramsTrie(Node* root, string query);
void splitText(string query, vector<string> &words);
void deleteNgramTrie(Node* root, string ngram);
void recursiveParentDeletion(Node* node, Node *root);
#endif // TRIEAPI
当我尝试编译程序我得到关于所述pair.h该头文件中的错误(以g ++编译5.4 C++ 11):C++:pair.h编译器错误 - 对具有不完全的类型
trie.h:14:46: required from here
/usr/include/c++/5/bits/stl_pair.h:102:11: error: ‘std::pair<_T1, _T2>::second’ has incomplete type
_T2 second; /// @c second is a copy of the second object
^
In file included from trie.cpp:10:0:
trie.h:11:16: note: forward declaration of ‘struct NodeStruct’
typedef struct NodeStruct
我不明白我错在哪里。
*“当我尝试编译程序时”* - 什么程序?我没有看到一个程序。 – IInspectable
@iinspectable,你看到了什么?错误? :-P – WhiZTiM
@JimS,那些'typedef'在C++中是没用的,只是给代码添加了混乱。您不需要“Eloborated类型说明符” – WhiZTiM