title: redefinition of template<class T> in C++
body: <p>I have searched and searched for a solution to my problem but I cannot seem to find one. I am using Code::Blocks and I am getting a redefinition error of a template class.</p>
  
  <p>Here is my "vectorAux.h" file:</p>
  
  <pre><code>#ifndef vectoraux_h
  #define vectoraux_h
  
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  #include &lt;iostream&gt;
  
  template &lt;typename T&gt;
  void removeDup(std::vector&lt;T&gt; &amp; v);
  
  template &lt;typename T&gt;
  unsigned seqVectSearch(const std::vector&lt;T&gt; &amp; v, unsigned first,
                 unsigned last, const T&amp; target);
  
  template &lt;typename T&gt;
  void writeVector(const std::vector&lt;T&gt; &amp; v);
  
  #include "vectorAux.cpp"
  #endif
  </code></pre>
  
  <p>and here is my "vectorAux.cpp" file:</p>
  
  <pre><code>#include "vectorAux.h"
  
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  #include &lt;iostream&gt;
  
  template &lt;typename T&gt;
  void removeDup(std::vector&lt;T&gt; &amp; v)
  {
      std::vector&lt;int&gt; vector1;
      unsigned i, last = v.size();
  
      for(int j = 0; j &lt;= v.size(); j++)
      {
          std::cout &lt;&lt; seqVectSearch(v, j, last, j);
          if(seqVectSearch(v, j, last, j) != v[i])
              vector1.push_back(seqVectSearch(v, j, last, j));
      }
  }
  
  template &lt;typename T&gt;
  unsigned seqVectSearch(const std::vector&lt;T&gt; &amp; v, unsigned first,
                         unsigned last, const T&amp; target)
  {
      unsigned i = first;
      while((v[i] != target) &amp;&amp; (v[i] &lt;= last))
      {
          if(v[i] == target)
              return i;
          i++;
      }
      return last;
  }
  
  template &lt;typename T&gt;
  void writeVector(const std::vector&lt;T&gt; &amp; v)
  {
      unsigned i;
      unsigned n = v.size();
  
      for (i = 0; i &lt; n; i++)
          std::cout &lt;&lt; v[i] &lt;&lt; ' ';
      std::cout &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>the final file for this program is "vectorDriver.cpp" but this one has no errors. This one just runs the program by calling the functions:</p>
  
  <pre><code>#include "vectorAux.h"
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  void fillVector(std::vector&lt;int&gt; &amp; vect);
  
  int main()
  {
    using namespace std;
  
    vector&lt;int&gt; vect;
  
    fillVector(vect);
    cout &lt;&lt; "Testing removeDup" &lt;&lt; endl;
    cout &lt;&lt; "Original vector is  ";
    writeVector(vect);
  
    removeDup(vect);
    cout &lt;&lt; "Vector with duplicates removed is  ";
    writeVector(vect);
    cout &lt;&lt; endl;
    writeVector(vect);
  
    return 0;
  }
  
  void fillVector(std::vector&lt;int&gt; &amp; vect)
  {
    int arr[] = {1,7,2,7,9,1,2,8,9};
    unsigned arrsize = sizeof(arr)/sizeof(int);
  
    vect = std::vector&lt;int&gt;(arr, arr+arrsize);
  }
  </code></pre>
  
  <p>I would really appreciate any and all help/advice that is given! I have looked around for a while and each source that I have found has said to guard the header file, but I have already done that and my problem still ensues.</p>