Hello all,
I am trying to write the constructor for the HashTable class, so it will create an array when a HashTable object is created. With the code below, I am getting the errors:
error C2466: cannot allocate an array of constant size 0
error C2133: 'arrayTest' : unknown size
Is it a problem to create an array in the constructor?
I have also tried calling a function to create the array, but get the same errors.
#include "utility.h"
#include "Key.h"
#include "HashTable.h"
using namespace std;
int main()
{
HashTable<Key> hTable1(97);
cout << "hello world" << endl;
}
#ifndef HASHTABLE_H
#define HASHTABLE_H
#include "utility.h"
#include "Key.h"
#include <list>
using namespace std;
template <class Key>
class HashTable
{
public:
HashTable(int array_size); //constructor
//Post: A hash table of size array_size been created.
};
template <class Key>
HashTable<Key>::HashTable(int array_size)
{
int size = array_size;
int arrayTest[size];
cout << "size: " << size << endl;
cout << "made it " << endl;
}
#endif //HASHTABLE_H