在自定义哈希表头文件中包括自定义链表
Include custom Linked List in custom Hash Table header files
我正在尝试创建自己的哈希表以使用我已经创建的链表。链表位于一个单独的文件夹中,Codenvy不允许我在头文件中使用它。
我尝试过相对和绝对途径,例如:
#include "../LinkedList/LinkedList.h"
#ifndef HASH_TABLE
#define HASH_TABLE
#include "../LinkedList/LinkedList.h"
template <typename T>
class HashTable {
public:
HashTable(); // Constructor
~HashTable(); // Destructor
void add (T); // add to the corresponding list
protected:
LinkedList<T>[] table; // includes linked lists to carry all data
private:
int hashIndex (T); // Finds the index of an element
};
#endif
我期望 c++ 允许由自定义对象组成的数组,但我可能大错特错了。错误是:
In file included from Main.cpp:2:0:
HashTable.h:12:22: error: expected unqualified-id before ‘[’ token
LinkedList<T>[] table;
^
尝试:
LinkedList<T> table[size];
请记住:数组的大小必须是恒定的,并且在编译时是已知的
相关文章:
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- C++自定义比较函数
- 如何比较自定义类的std::变体
- std::设置自定义比较器
- 如何正确实现和访问运算符的各种自定义枚举器
- flutter:即使shouldRepaint()返回true,自定义画家也不会重新绘制
- 自定义先决条件对移动分配运算符有效吗
- 使用VS Code和CMake Tools运行自定义命令
- 如何创建从Maya(或类似程序)到虚幻引擎的自定义数据导出插件
- std::ranges::elements_view,用于自定义类似元组的数据
- 跟随整数索引列表的自定义类迭代器
- 自定义分配器,包括放置新案例
- 在自定义哈希表头文件中包括自定义链表
- 我正在声明一个自定义优先级队列,包括 pair<pair<int,int>int >,如何清除它?
- 为什么在对自定义对象的向量进行分类时,我们将在struct的定义中包括比较函数
- Qt外部库包括内部自定义库
- 将Windows 7窗口标记为始终位于顶部,包括Win7任务栏(自定义错误)
- 使用自定义UIAlertView xCode - 包括对话框/文本
- 自定义库在应用程序中,我必须包括库依赖头两次