title: explicit instantiation but no definition available when build template function used by template class
body: <pre><code>#ifndef _QUEUE_HPP
  #define _QUEUE_HPP
  #include &lt;iostream&gt;
  #include &quot;Node.hpp&quot;
  
  namespace std{
    
    template&lt;typename T&gt;
    class Queue{
      public:
      class Node&lt;T&gt;* front;
      class Node&lt;T&gt;* rear;
      Queue();
      void enqueue(T data);
      T dequeue();
      ~Queue();
      template&lt;class U&gt;
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out,Queue&lt;U&gt; const&amp; queue);
    };
    template&lt;class classT&gt;
      std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out,Queue&lt;classT&gt; const&amp; queue);
  
    template class Queue&lt;double&gt;;
    
    template std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out,Queue&lt;double&gt; const&amp; queue);
  }
  #endif
  </code></pre>
  <p><strong>Compile result</strong><br></p>
  <p>g++ -std=c++11 main.cpp Stack.o Queue.o -o test</p>
  <p>In file included from main.cpp:2:0:</p>
  <p>Queue.hpp: In instantiation of &lsquo;std::ostream&amp; std::operator&lt;&lt;(std::ostream&amp;, const std::Queue&lt;classT&gt;&amp;) [with classT = double; std::ostream = std::basic_ostream&lt;char&gt;]&rsquo;:</p>
  <p>Queue.hpp:25:81: &nbsp; required from here</p>
  <p>Queue.hpp:25:81: error: explicit instantiation of &lsquo;std::ostream&amp; std::operator&lt;&lt;(std::ostream&amp;, const std::Queue&lt;classT&gt;&amp;) [with classT = double; std::ostream = std::basic_ostream&lt;char&gt;]&rsquo; but no definition available [-fpermissive]</p>
  <p>&nbsp;mplate std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out,Queue&lt;double&gt; const&amp; queue);</p>
  <p><br></p>
  <p><strong>Problem:<br></strong>
  <strong>What happens with my code? I believe I have template operator&lt;&lt;being defined but the compiler can't find a definition.</strong></p>