title: why I get this error while using templates in c++
body: <p>I am new to Templates and trying to get <strong>name</strong> and <strong>item</strong> but I run into weird error. I thought the problem was the <strong>string</strong> so I changed to <strong>int</strong> but it didn't work. can you help me please. Thank you!
  when i delete the templates form cpp class i get many different errors even tho i am defining them in hpp file </p>
  
  <p><strong>Template.hpp</strong></p>
  
  <pre><code>#ifndef Template_hpp
  #define Template_hpp
  
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  template &lt;typename T1 ,typename  T2&gt;
  class Temp
  {
  private:
      T1 item;
      T2 name;
  
  public:
      Temp();
      Temp(T1 item, T2 name);
      T1 getItem();
      T2 getName();
  
  };
  #endif /* Template_hpp */
  </code></pre>
  
  <p><strong>Template.cpp</strong></p>
  
  <pre><code>#include "Template.hpp"
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  template &lt;typename T1 ,typename  T2&gt;
  Temp&lt;T1,T2&gt;:: Temp()
  {
  
  }
  template &lt;typename T1 ,typename  T2&gt;
  
  Temp&lt;T1, T2&gt;::  Temp( T1 item, T2 name)
  {
      this-&gt;item=item;
      this-&gt;name=name;
  }
  template &lt;typename T1 ,typename  T2&gt;
  T1 Temp&lt;T1,T2&gt;:: getItem()
  {
      return this-&gt;item;
  }
  
  template &lt;typename T1 ,typename  T2&gt;
    T2 Temp&lt;T1,T2&gt;::getName()
  {
      return this-&gt;name;
  }
  </code></pre>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include&lt;string&gt;
  #include "Template.hpp"
  using namespace std;
  
  int main(int argc, const char * argv[]) {
  
      //Error here 
      Temp&lt;int,string&gt;t1(10,"zaid");
      t1.getName();
      return 0;
  }
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Showing All Issues
  Undefined symbol: Temp&lt;int, std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt;::Temp(int, std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;)
  </code></pre>