// hi
注释会导致红色波浪线出现在、 和它下面的if
语句中、hashTable
、ItemType*
和hashTableSize
。错误是“预期的if
声明”,hashTable
错误是“此声明没有存储类或类型说明符”,ItemType*
错误是“预期的类型说明符”,hashTableSize
错误是“标识符'HashTableSize'未定义。删除注释删除波浪线。我的项目中没有其他班级有这个问题。什么给了?
template <class ItemType>
HashedDictionary( const unsigned & p_hashTableSize = DEFAULT_SIZE ) : hashTable( NULL ), hashTableSize( p_hashTableSize ), itemCount( 0 )
{
// hi
if ( hashTableSize < 0 )
throw PrecondViolatedExcep( "Hash table size must be greater than or equal to zero." );
hashTable = new ItemType*[ hashTableSize ];
}
类声明:
#include "HashedEntry.h"
template< class ItemType>
class HashedDictionary
{
private:
HashedEntry<ItemType>** hashTable;
unsigned hashTableSize;
unsigned itemCount;
static const unsigned DEFAULT_SIZE = 101;
int getHashIndex( const ItemType & newEntry );
int computeIndex( const ItemType & newEntry );
public:
HashedDictionary( const unsigned & p_hashTableSize );
bool add( const ItemType & newItem );
}