title: Copy constructor of template class
body: <p>I read that template copy-con is never default copy  onstructor, and template assignment-op is never a copy assignment operator. </p>
  
  <p>I couldn't understand why this restriction is needed and     straight away went online to ideone and return a <a href="http://ideone.com/xzBXvk" rel="noreferrer">test program</a> but here copy constructor never gets called on further googling I came across templatized constructor and tried that but still it never calls copy constructor. </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  template &lt;typename T&gt; class tt
  {
      public :
      tt()
      {
          std::cout &lt;&lt; std::endl &lt;&lt; "   CONSTRUCTOR" &lt;&lt; std::endl;
      }
      template &lt;typename U&gt; const tt&lt;T&gt;&amp; operator=(const tt&lt;U&gt;&amp; that){std::cout &lt;&lt; std::endl &lt;&lt; "   OPERATOR" &lt;&lt; std::endl;}
      template &lt;typename U&gt; tt(const tt&lt;U&gt;&amp; that)
      {
          std::cout &lt;&lt; std::endl &lt;&lt; "    COPY CONSTRUCTOR" &lt;&lt; std::endl;
      }
  };
  
  
  tt&lt;int&gt; test(void)
  {
      std::cout &lt;&lt; std::endl &lt;&lt; "      INSIDE " &lt;&lt; std::endl; tt&lt;int&gt; a; return a;
  }
  
  int main() {
      // your code goes here
      tt&lt;int&gt; a ; a = test();
  
      return 0;
  }
  </code></pre>
  
  <p>Can someone explain me   the whole reason behind putting this restriction and also how to write a copy constructor of template class.</p>
  
  <p>Thanks</p>