gpt4 book ai didi

c++:pair.h 编译器错误 - pair 的类型不完整

转载 作者:太空宇宙 更新时间:2023-11-04 13:05:26 26 4
gpt4 key购买 nike

<分区>

#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 中编译):

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

我不明白我哪里错了。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com