title: Pointer to a template Object
body: <p>I cannot compile... I have no idea what's wrong here... This is where the errors occur:</p>
  
  <pre><code>void MainThread::run()
  {
      Set&lt;int&gt;* p_test; p_test = new Set&lt;int&gt;;
      p_test-&gt;add(new int(9));
      std::cout&lt;&lt;"The set is: {";
      for (int x = 0; x &lt; p_test-&gt;size(); x++)
          std::cout&lt;&lt; ", " &lt;&lt; p_test-&gt;toString(x).toStdString().c_str();
  
      std::cout&lt;&lt;"}";
  
      std::cin.get();
  }//test method
  </code></pre>
  
  <p>The error message is given as: "undefined reference to Set::Set()" and it shows up on the line that I try to use my class. My class compiles on its own... Below is the file "Set.h". Anybody have any idea as to how I can fix it? Thanks in advance.</p>
  
  <pre><code>#ifndef SET_H
  #define SET_H
  
  #include &lt;functional&gt;
  #include &lt;QList&gt;
  #include &lt;QString&gt;
  #include &lt;type_traits&gt;
  #include &lt;exception&gt;
  #include &lt;iostream&gt;
  
  template&lt;typename T&gt;
  class Set {
  public:
      //constructors
      Set();
      ~Set(){ delete []pType; }
  
      //functions
      const int &amp; size(){ return m_size; }
  
      void add(const T * singleton);
  
      void empty();
  
      //operators
      inline T&amp; operator [](int index){ return pType[index]; }
  
      template&lt;class Y&gt;
      friend Set&lt;Y&gt; operator *(const Set&lt;Y&gt;&amp; s1, const Set&lt;Y&gt;&amp; s2);//intersection
      template&lt;class Y&gt;
      friend Set&lt;Y&gt; operator *(Set&lt;Y&gt;&amp; s1, Set&lt;Y&gt;&amp; s2);
      template&lt;class Y&gt;
      friend Set&lt;Y&gt; operator +(const Set&amp; s1, const Set&amp; s2);//union
      template&lt;class Y&gt;
      friend Set operator -(const Set&amp; s1, const Set&amp; s2);//relative complement
  
      bool operator =(const Set&amp; other)
      {
          delete []pType;//empty out the array
  
          /** Gets operator **/
          int x = other.size();
          pType = new T[x];
          for (int y = 0; y &lt; x; y++)
              pType[y] = other[y];
  
          m_size = x;
  
          return true;
      }
  
      bool operator ==(const Set &amp; other)
      {
          if(other.size() != size())
              return false;
          else
          {
              for (int x = 0; x &lt; size(); x++)
                  if (!other.has(pType[x]))
                      return false;
          }//end else
          return true;
      }//end equals operator
  
      /*template&lt;typename Type&gt;
      bool operator *= (const Set&lt;Type&gt; &amp;lhs, const Set&lt;Type&gt; &amp;rhs){
          //compile time statement (just to let people know)
          static_assert(std::is_same&lt;Type1, Type2&gt;::value, "Types are not equal!");
          return std::is_same&lt;Type1, Type2&gt;::value;
      }//operator for checking if two things are the same type */
  
      bool operator &gt;(const Set &amp;other)
      { /** Superset **/ return false; }
      \
      bool operator &lt;(const Set *other)
      { /** Subset **/ return false; }
  
      Set&amp; complement();
      bool isEmpty(){ return m_size == 0; }
      bool has(T* element);
      QString toString(int index);
  
  private:
      T * pType;
      T * m_Type; //save the variable type.
      int m_size;
  };
  
  #endif // SET_H
  </code></pre>
  
  <p>I do have a constructor defined in a separate file. </p>
  
  <pre><code>Set&lt;Y&gt;::Set()
  {
      m_size = 0;
      m_Type = new Y();//save a default value
  }//create an empty set
  </code></pre>
  
  <p>Or do I need a different kind of constructor?</p>