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