title: (C++) Constructor for HashTable
body: <p>I'm trying to create a class for a HashTable implementation</p>
  
  <p>Since I'm doing a chained HashTable, my hashTable starts out as a an array of pointers of type "object".</p>
  
  <p>What I am having trouble with is my constructor since in my main file, I'm going to take in a value for the size of the array. Like this:</p>
  
  <pre><code>int N;
  scanf("%d", &amp;N);
  //Create HashTable Object
  HashTable *hash = new HashTable(N);
  </code></pre>
  
  <p>This is my .h file:</p>
  
  <pre><code>class HashTable {
  
      int arraySize;
  
      typedef struct object {
          string data;
          object *nextptr;
      } object;
  
      object** table;
  public:
      //Constructor
      HashTable(int size);
  
      /// ...and other methods...
  </code></pre>
  
  <p>For my constructor implementation I keep getting error:
  Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)</p>
  
  <p>So I know I'm doing something wrong.</p>
  
  <p>This is my Constructor implementation.</p>
  
  <pre><code>//Constructor
  HashTable :: HashTable(int size){
      this-&gt;arraySize = size;
      this-&gt;table = new object[size]; //&lt;-- this is giving me issues!!
  
      for (int i = 0; i &lt; arraySize; i++) {
          table[i] = new object;
          table[i]-&gt;data = "";
          table[i]-&gt;nextptr = NULL;
      }
  
  }
  </code></pre>
  
  <p>If someone could help me out here that'd be greatly appreciated... new to this sort of stuff.</p>
  
  <p>EDIT:
  The assignment requires us to use arrays and not vectors.</p>
  
  <p>I think I need to use an array of pointers since every index in the array is going to hold a linked list of objects that have "collided" with the same index.</p>