c++ - 在堆上实例化一个对象

标签 c++ object compiler-errors heap-memory

我收到错误:

hashing.cpp: In function ‘int main(int, char**)’:
hashing.cpp:96: error: expected type-specifier before ‘Linked_HashTable’
hashing.cpp:96: error: cannot convert ‘int*’ to ‘LinkedList_HashTable*’ in initialization
hashing.cpp:96: error: expected ‘,’ or ‘;’ before ‘Linked_HashTable’

编译我的代码时。我想我遗漏了一些很容易弄清楚的东西。

给我错误的代码是:

Array_HashTable *linear_div_hash = new Array_HashTable(sizeDiv);
LinkedList_HashTable *chain_div_hash = new Linked_HashTable(sizeDiv);
Array_HashTable *doubleHash = new Array_HashTable(sizeDiv);

Array_HashTableLinkedList_HashTable() 的构造函数都采用整数,例如 sizeDiv。非常感谢任何帮助。

谢谢!

最佳答案

应该

LinkedList_HashTable *chain_div_hash = new Linked_HashTable(sizeDiv); 

成为

LinkedList_HashTable *chain_div_hash = new LinkedList_HashTable(sizeDiv);

? (请注意您的代码中缺少的 List)。

关于c++ - 在堆上实例化一个对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5453980/

相关文章:

c++ - QWebSocketServer - 不释放内存

c++ - 具有 `stdio.h` 函数的模板和名称查找

mysql - mysql中的对象存储

c++ - C++ 中的精度相关错误

c++ - 服务器 UDP 函数 recvfrom

c++ - 非静态成员的无效使用

c++ - openPersistentEditor 中的 QSortFilterProxyModel

c++ - 当我尝试将 char* 分成标记时出现段错误

java 。对象实例发生奇怪的变化

python - 处理对象操作