title: C++ template - error: expected initializer before '<' token
body: <p>I am trying to learn about templates, I want my class pair to be able to hold two objects of any type. I just want to provide an accessor function for obj1 now. But I get the following error when I try to complile:</p>
  
  <pre><code>error: expected initializer before '&lt;' token
      T1 pair&lt;T1,T2&gt;::getObj1()
  </code></pre>
  
  <p>My code is:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  using namespace std;
  
  template &lt;class T1, class T2&gt;
  class pair
  {
    public:
      pair(const T1&amp; t1, const T2&amp; t2) : obj1(t1), obj2(t2){};
  
      T1 getObj1();
  
    private:
      T1 obj1;
      T2 obj2;
  };
  
  template &lt;class T1, class T2&gt;
  T1 pair&lt;T1,T2&gt;::getObj1()
  {
      return obj1;
  }
  
  
  
  int main()
  {
      return 0;
  }
  </code></pre>