在堆上实例化对象

发布于 2024-10-27 07:50:49 字数 691 浏览 2 评论 0原文

我收到错误:

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_HashTable 和 LinkedList_HashTable() 的构造函数都采用像 sizeDiv 这样的整数。非常感谢任何帮助。

谢谢!

I receive the error:

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’

When compiling I my code. I think I am missing something pretty easy to figure out.

The code that is giving me the error is:

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);

Where the constructor for both Array_HashTable and LinkedList_HashTable() takes an integer like sizeDiv is. Any help is greatly appreciated.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沉溺在你眼里的海 2024-11-03 07:50:49

应该

LinkedList_HashTable *chain_div_hash = new Linked_HashTable(sizeDiv); 

LinkedList_HashTable *chain_div_hash = new LinkedList_HashTable(sizeDiv);

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

Should

LinkedList_HashTable *chain_div_hash = new Linked_HashTable(sizeDiv); 

be

LinkedList_HashTable *chain_div_hash = new LinkedList_HashTable(sizeDiv);

? (Note the missing List in your code).

野鹿林 2024-11-03 07:50:49
LinkedList_HashTable *chain_div_hash = new LinkedList_HashTable(sizeDiv);

也许您输入了 Linked_HashTable 但修改了 LinkedList_HashTable

LinkedList_HashTable *chain_div_hash = new LinkedList_HashTable(sizeDiv);

Maybe you typed Linked_HashTable but ment LinkedList_HashTable?

素罗衫 2024-11-03 07:50:49

看起来您在 LinkedList_HashTable *chain_div_hash = new Linked_HashTable(sizeDiv); 行上将 LinkedList_HashTable 错误地输入为 Linked_HashTable,导致编译器认为 Linked_HashTable(sizeDiv); 是对返回 int 的隐式声明函数的函数调用。

It looks like you mistyped LinkedList_HashTable as Linked_HashTable on the line LinkedList_HashTable *chain_div_hash = new Linked_HashTable(sizeDiv); causing the compiler to think Linked_HashTable(sizeDiv); is a function call to an implicitly declared function that returns an int.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文