Reputation: 71
I'm having this errors in the code:
Error is found in this line in private functions:
vector<HashEntry> array;
#ifndef _HASHTABLE_H
#define _HASHTABLE_H
#include <vector>
enum EntryType { ACTIVE, EMPTY, DELETED };
Template <class HashedObj>
struct HashEntry
{
HashedObj element;
EntryType info;
HashEntry( const HashedObj & e = HashedObj( ), EntryType i = EMPTY )
: element( e ), info( i ) { }
};
template <class HashedObj>
class HashTable
{
private:
vector<HashEntry> array;
int currentSize;
const HashedObj ITEM_NOT_FOUND;
bool isActive( int currentPos ) const;
int findPos( const HashedObj & x ) const;
public:
explicit HashTable( const HashedObj & notFound, int size = 101 );
HashTable( const HashTable & rhs )
: ITEM_NOT_FOUND( rhs.ITEM_NOT_FOUND ),
array( rhs.array ), currentSize( rhs.currentSize ) { }
const HashedObj & find( const HashedObj & x ) const;
void makeEmpty( );
void insert( const HashedObj & x );
void remove( const HashedObj & x );
const HashTable & operator=( const HashTable & rhs );
};
#endif
How can I fix this error C4430?
Upvotes: 1
Views: 4871
Reputation: 1
HashEntry
itself is a template class, and doesn't automatically deduce the template parameter type from the containing HashTable
class. You need to change the array
declaration as follows
template <class HashedObj>
class HashTable {
private:
std::vector<HashEntry<HashedObj>> array;
// ^^^^^^^^^^^
// ...
};
Upvotes: 0