Instantiating an object on the Heap
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!
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).
LinkedList_HashTable *chain_div_hash = new LinkedList_HashTable(sizeDiv);
Maybe you typed Linked_HashTable
but ment LinkedList_HashTable
?
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
.
精彩评论