我正在尝试创建模板对象的向量向量。当我尝试调整内部向量的大小并且我无法制作错误消息的头部或尾部时会发生错误。我不知道它从哪里得到 HashTable::Item::Item。有什么建议么?
/usr/include/c++/4.4.6/bits/stl_vector.h(552):错误:没有构造函数实例“HashTable::Item::Item [with Key=int, Value=Varvalue]”匹配参数列表调整大小(size_type __new_size, value_type __x = value_type())
detected during: instantiation of "void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type={size_t={unsigned long}}, std::vector<_Tp, _Alloc>::value_type) [with _Tp=HashTable<int, Varvalue>::Item, _Alloc=std::allocator<HashTable<int, Varvalue>::Item>]" at line 118 of "main.cc"
以下是相关代码:
#define VECLEN 16
类 Varvalue
{
上市:
字符数据[32];
};
模板
类哈希表
{
私人的:
类项目
{
上市:
布尔有效;
钥匙钥匙;
价值价值;
项目 *下一个;
Item(const Key k, const Value v, Item *b = 0, bool val = true):
键(k),值(v),下一个(b),有效(val){}
};
vector<vector<Item> > table;
int tableSize;
HashTable(const int s): tableSize(s)
{
table.resize(tableSize);
for(int i=0; i<table.size(); i++)
table[i].resize(VECLEN); // <<-- error line 118
}
}
int main()
{
HashTable<int, Varvalue> htable(nkeys);
}