I am trying to create a vector of vector of a template object. The error occurs when I try to resize the inner vector and I can't make heads or tail of the error message. I don't know where it gets the HashTable::Item::Item from. Any suggestions?
/usr/include/c++/4.4.6/bits/stl_vector.h(552): error: no instance of constructor "HashTable::Item::Item [with Key=int, Value=Varvalue]" matches the argument list resize(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"
Here is the relevant code:
#define VECLEN 16 class Varvalue { public: char data[32]; };template class HashTable { private: class Item { public: bool valid; Key key; Value value; Item *next;
Item(const Key k, const Value v, Item *b = 0, bool val = true): key(k), value(v), next(b), valid(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); }