title: Program doesnt use output operator
body: <p>I'm currently working on a program that should be a queue as a doubly linked list. The program works, but my problem is that it doesn't use the output operator for 'Queue_element'. It just uses the standard output operator. How do i need to change my program that it would use it?</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  template&lt;typename T&gt; class Queue;
  
  template&lt;typename T&gt; class Queue_element {
  private:
      T value;
      Queue_element&lt;T&gt;* next;
      Queue_element&lt;T&gt;* prev;
  
  public:
      Queue_element() { value = 0; next = nullptr; prev = nullptr; }
      Queue_element(T n) { value = n; next = nullptr; prev = nullptr; }
  
      template&lt;typename S&gt; friend ostream&amp; operator&lt;&lt;(ostream&amp; os, const Queue_element&lt;S&gt;&amp; queue_el);
      template&lt;typename S&gt; friend ostream&amp; operator&lt;&lt;(ostream&amp; os, const Queue&lt;S&gt;&amp; queue);
      friend class Queue&lt;T&gt;;
  };
  
  template&lt;typename T&gt; class Queue {
  private:
      Queue_element&lt;T&gt;* head;
      Queue_element&lt;T&gt;* tail;
  
  public:
      Queue() { head = nullptr; tail = nullptr; }
      void push(T n);
      bool empty() const;
  
      template&lt;typename S&gt; friend ostream&amp; operator&lt;&lt;(ostream&amp; os, const Queue&lt;S&gt;&amp; queue);
  };
  
  template&lt;typename T&gt; bool Queue&lt;T&gt;::empty() const
  {
      if (this-&gt;head == nullptr &amp;&amp; this-&gt;tail == nullptr) { return true; }
      else return false;
  };
  
  template&lt;typename T&gt; void Queue&lt;T&gt;::push(T n) {
      Queue_element&lt;T&gt;* q = new Queue_element&lt;T&gt;(n);
      if (this-&gt;empty()) { this-&gt;head = q; this-&gt;tail = q; }
      else { this-&gt;tail-&gt;next = q; q-&gt;prev = tail; this-&gt;tail = q; }
  }
  
  template&lt;typename S&gt;
  ostream&amp; operator&lt;&lt;(ostream&amp; os, const Queue_element&lt;S&gt;&amp; queue_el) {
      os &lt;&lt; queue_el.value;
      return os;
  }
  
  template&lt;typename S&gt;
  ostream&amp; operator&lt;&lt;(ostream&amp; os, const Queue&lt;S&gt;&amp; queue){
      Queue_element&lt;S&gt;* q = queue.head;
      while(q != nullptr){
          os &lt;&lt; q-&gt;value &lt;&lt; " ";
          q = q-&gt;next;
      }
  return os;
  }
  
  int main()
  {
      Queue&lt;string&gt; q1;
      q1.push("test");
      cout &lt;&lt; q1 &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>While this is the output operator i'm talking about:</p>
  
  <pre><code>template&lt;typename S&gt;
  ostream&amp; operator&lt;&lt;(ostream&amp; os, const Queue_element&lt;S&gt;&amp; queue_el) {
      os &lt;&lt; queue_el.value;
      return os;
  }
  </code></pre>
  
  <p>Would appreciate any help!  </p>