title: Undefined reference to 'HashTable::HashTable()'
body: <p>I'm working on a testing program for a lab and I keep getting the error </p>
  
  <pre><code>[jereminp@bondi hw3]$ make insert_test
  g++  -O3 -g -o insert_test.o -c insert_test.cc
  g++ -O3 -g -o insert_test insert_test.o
  insert_test.o: In function `main':
  /users/ugrad/2018/fall/jereminp/114/hw3/hw3/insert_test.cc:17: undefined reference to `HashTable::HashTable()'
  /users/ugrad/2018/fall/jereminp/114/hw3/hw3/insert_test.cc:24: undefined reference to `HashTable::insert(int)'
  /users/ugrad/2018/fall/jereminp/114/hw3/hw3/insert_test.cc:32: undefined reference to `HashTable::insert(int)'
  collect2: ld returned 1 exit status
  make: *** [insert_test] Error 1
  </code></pre>
  
  <p>I'm fairly certain I have the logic, but I can't get past this error and I feel like I'm missing something simple. Here's the parts of the code in question. </p>
  
  <p>Makefile</p>
  
  <pre><code>CC = g++
  CFLAGS =
  COPTFLAGS = -O3 -g
  
  insert_test: insert_test.o
      $(CC) $(COPTFLAGS) -o $@ $^
  </code></pre>
  
  <p>insert_test.cc</p>
  
  <pre><code>#include "HashTable.h"
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;math.h&gt;
  
  using namespace std;
  class HashTable;
  
  int main(int argc, char* argv[])
  {
    //checks .5 and .9 1x
    int numRuns = 0;
    int numProbes = 0;
    int a=0;
    HashTable h;
  </code></pre>
  
  <p>HashTable.hh</p>
  
  <pre><code>#ifndef HASHTABLE_H
  #define HASHTABLE_H
  
  
  class HashTable
  {
    public:
    HashTable();
    /* implement copy constructor, assignment, destructor if needed */
    int hashfnc(int key);
    int insert (int value); 
    /* insert the input value and return the number of probes
     * return -1 if the table is full and insert fails */
  
    bool find (int value, int&amp; nProbes);  
    /* Search for the input value in table
     * Return true if the search is successful, otherwise false
     * Save # probes in 'nProbes' */
  
    // getters
    int capacity() { return nSlot; }
    int size() { return nElem; }
    double load_factor() { return load; }
    int getSearchProbes() { return probesSearch; }
  
    private:
    /* declare your data */
    double load;     // track the load factor of table
    int    nSlot;    // # slots i.e. max # elements can hold 
    int    nElem;    // current # elements in table
    int    arr[];
    int    probesSearch;
  };
  
  #endif
  </code></pre>
  
  <p>HashTable.cc</p>
  
  <pre><code>#include "HashTable.h"
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;math.h&gt;
  
  using namespace std;
  
  class HashTable
  {
    public:
  
  
    HashTable()
    {
      load = 0;
      nSlot = 300;//nSlot is changable in order to optimize
      nElem = 0;
      arr = new int[nSlot];
      probesSearch=0;
      for(int i = 0;i&lt;nSlot;i++)
      {
        arr[i] = NULL;
      }
    }
  </code></pre>
  
  <p>Some of the things I've tried are adding any and all includes I could think of, changing the last line shown in insert_test.cc to "HashTable h = new HashTable();"(where I got a different error), adding namespace std to the header. I feel like it should be a quick fix but at the same time I can't find the solution anywhere. Plz send help</p>