不完整的类型,正向声明
incomplete type, forward declaration
我只是在学习C ,我遇到了很多问题。目前,我正在尝试用堆和一个标签实现频率队列,因此我正在尝试为哈希表条目和堆条目制作结构。我所做的是...
1 #include<iostream>
2 #include<string>
3 #include "freqq.h"
4
5 using namespace std;
6
7
8
9
10 struct _hashEntry {
11 string word;
12 int heapPstn;
13 };
14
15 struct _heapEntry {
16 int frequency;
17 hashEntry* wordInHash;
18 };
^^ the .cpp,
1 #define FREQQ_H_
2 #include <string>
3
4 using namespace std;
5
6 class FreqQ {
7 public:
8 struct _heapEntry;
9 typedef struct _heapEntry heapEntry;
10
11 struct _hashEntry;
12 typedef struct _hashEntry hashEntry;
13
^^ .h。为了简单起见,我已经消除了其他方法。
我遇到了错误不完整类型的使用freqq :: _ hepentry -hepentry-使用无效的使用freqq.h:8:10:错误:freqq :: _hepentryâ
的前向声明我无法弄清楚为什么我的一生。
任何想法??
谢谢!
我不明白。您正在定义.cpp中的_hashEntry
和_heapEntry
结构?
将结构声明移至class FreqQ
声明之前的.h,其中使用了结构。
相关文章:
- std::enable_if 更改成员 *变量* 声明/类型
- 对前向声明类型进行unique_ptr的解决方法
- 如何将声明类型作为参数发送
- 在 Fortran 中泛化特定声明类型的操作
- 使用 (c++11) 声明类型时放置 __declspec(dllimport) 关键字的位置
- 模板函数可以使用带有删除的构造函数的声明类型
- 声明类型没有任何可变类型
- 如何使用声明类型简化此代码
- 使用声明类型选择函数专业化
- 替代班级内声明类型的别名
- 对于自动键入推论的参数,声明类型(自动)应推导的内容
- 使用 decltype 的条件声明类型
- 您如何声明类型结构的堆栈?在C 中
- 将指向前向声明类型的指针推送到 typedef'd 向量时出现编译器错误
- 声明适用于 auto,但不能显式声明类型?
- 声明类型包含未展开的参数包'Args'
- 课堂上的Typedef.在另一个类错误中:尚未声明类型
- 冲突的声明类型/价值不匹配
- 获取具有AST访问者clang的功能声明类型
- 变量声明类型定义 C 中的约定