title: C++ error LNK2019: unresolved external symbol
body: <pre><code>#ifndef SET_H
  #define SET_H
  
  #include &lt;iostream&gt;
  using namespace std;
  
  template&lt;class ItemType&gt;
  class Set;
  
  
  template &lt;class ItemType&gt;
  class Set{
    private:
            ItemType *elements; // This is a sample representation
            int capacity; // You are free to use other representations
            int num_of_elements;
    public: 
            Set(); // Constructor
            Set(const Set&lt;ItemType&gt;&amp; other); // Copy Constructor
            ~Set(); // Destructor
  
            /**Member Functions**/
  
            void  addElement (const ItemType &amp;element);
            /* Add the element to the set. 
            If the element is already in the set DO NOT add it. */
  };
  #endif
  
  
  #include &lt;iostream&gt;
  #include "set.h"
  using namespace std;
  
  
  template &lt;class ItemType&gt;
  Set&lt;ItemType&gt;::Set(){
          elements = new ItemType[20];
          num_of_elements = 0;
          capacity = 10;
  } 
  
  template &lt;class ItemType&gt;
  Set&lt;ItemType&gt;::Set(const Set&lt;ItemType&gt;&amp; other):
      elements(other-&gt;elements), num_of_elements(other-&gt;num_of_elements), capacity(other-&gt;capacity)
  {}
  
  template &lt;class ItemType&gt;
  Set&lt;ItemType&gt;::~Set(){
  delete[] elements;
  }
  
  template &lt;class ItemType&gt;
  void Set&lt;ItemType&gt;::addElement (const ItemType &amp;element){
          ItemType * temp = new ItemType [capacity];
          for( int i = 0; i &lt; num_of_elements ; i ++ ) {
          temp[i] = elements[i];}
  
              delete [] elements;
              elements = temp;
  
              elements[num_of_elements] = element;
              num_of_elements++;
  }
  
  template &lt;class ItemType&gt;
  bool Set&lt;ItemType&gt;::removeElement(const ItemType &amp;item){
          for( int i = 0; i &lt; _size; i++ ) {
          if( _items[i] == item )
          }
          int place = i;
          if( place == -1 )
          return false;
  
          elements[place]= elements[num_of_elements-1];
          num_of_elements --;
          return true;
  }
  
  
  
  #include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include "set.h"
  
  using namespace std;
  
  int main(){
  
      Set&lt;int&gt; s;
      int x=8;
      s.addElement(x);
  
      for (int i=0;i&lt;5;i++)
          s.addElement(i+6);
  
      cout &lt;&lt; "s: " &lt;&lt; s &lt;&lt; endl;
  
  
  
  
      system("pause");
      return 0;
  }
  
  
  
  This is the code that i write but  i'm getting the following error.
  
  1&gt;Main.obj : error LNK2019: unresolved external symbol "public: __thiscall Set&lt;int&gt;::Set&lt;int&gt;(void)" (??0?$Set@H@@QAE@XZ) referenced in function _main
  1&gt;Main.obj : error LNK2019: unresolved external symbol "public: __thiscall Set&lt;int&gt;::~Set&lt;int&gt;(void)" (??1?$Set@H@@QAE@XZ) referenced in function _main
  1&gt;Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Set&lt;int&gt;::addElement(int const &amp;)" (?addElement@?$Set@H@@QAEXABH@Z) referenced in function _main
  1&gt;Main.obj : error LNK2019: unresolved external symbol "class std::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt; &amp; __cdecl operator&lt;&lt;(class std::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt; &amp;,class Set&lt;int&gt; const &amp;)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$Set@H@@@Z) referenced in function _main
  </code></pre>
  
  <hr>
  
  <p>That's the code that i write it's a homework about templates but i'm getting some annoying errors.</p>
  
  <h2>i couldn't find the source of the error messages i think its about templates how can i solve these problems?</h2>