title: output operator overloading for queue class C++
body: <p>I am trying to overload the &lt;&lt; operator in order to print objects of classes, I tried making a friend function of the operator and then declaring it in below the Queue class, I have not written anything inside the code block here is what I have, it wont compile, it will crash instantly, thanks in advance.</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  
  class Employee{
  
  protected:
      long empId;
      string empName;
      string email;
  public:
          Employee(){}
          Employee(long i, string n){
           empName = n,
           empId =i;
           email = "Unknown";
      }
  };
  
  class Student{
  
  protected:
      long stId;
      int year;
      string email;
      string schoolName;
  public:
      Student(){}
      Student(long i, int y, string sn){
      stId = i;
      year =y;
      email = "Unknown";
      schoolName=sn;
      }
  };
  
  template&lt;class T&gt;
  class Queue{
  protected:
      vector&lt;T&gt; theQ;
  public:
      void Push(T item);
      T pop();
      void ReadAnItem();
      void PrintQ();
      **template&lt;T&gt;** edit
      friend ostream&amp; operator&lt;&lt; (ostream&amp; is, const Queue&lt;T&gt;&amp; theQ);
  };
  
  
  template&lt;class T&gt;
  ostream&amp; operator&lt;&lt; (ostream&amp; os, const Queue&lt;T&gt;&amp; theQ){
          **os &lt;&lt; theQ.Print();** Edit
      return os;
  }
  template&lt;class T&gt;
  void Queue&lt;T&gt;::ReadAnItem(){
      T item;
      cout &lt;&lt; "Enter the data please: " &lt;&lt; endl;
      cin &gt;&gt; item;
      Push(item);
  }
  
  template&lt;class T&gt;
  void Queue&lt;T&gt;::Push(T item){
      theQ.front() = item;
  }
  
  template&lt;class T&gt;
  void Queue&lt;T&gt;::PrintQ(){
      cout &lt;&lt; "The content of the array is as follows: " &lt;&lt; endl;
      for (int i=0; i&lt; theQ.size(); i++){
          cout &lt;&lt; theQ[i] &lt;&lt; **endl;** I get an "invalid overload of endl"
      }
  }
  </code></pre>