在堆上实例化对象
我收到错误:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
应该
是
? (请注意代码中缺少的
List
)。Should
be
? (Note the missing
List
in your code).也许您输入了
Linked_HashTable
但修改了LinkedList_HashTable
?Maybe you typed
Linked_HashTable
but mentLinkedList_HashTable
?看起来您在
LinkedList_HashTable *chain_div_hash = new Linked_HashTable(sizeDiv);
行上将LinkedList_HashTable
错误地输入为Linked_HashTable
,导致编译器认为Linked_HashTable(sizeDiv);
是对返回int
的隐式声明函数的函数调用。It looks like you mistyped
LinkedList_HashTable
asLinked_HashTable
on the lineLinkedList_HashTable *chain_div_hash = new Linked_HashTable(sizeDiv);
causing the compiler to thinkLinked_HashTable(sizeDiv);
is a function call to an implicitly declared function that returns anint
.