title: c++ redefine operator<() and operator!=()
body: <p>I have this implementation of queue:</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  template &lt;typename T&gt;
  struct elem_q
  {
  T inf;
  elem_q&lt;T&gt;* link;
  };
  
  template &lt;typename T = int&gt;
  class Queue
  {
  public:
      Queue();
      ~Queue();
      Queue(const Queue&amp;);
      Queue&amp; operator= (const Queue&amp;);
  
      bool empty()const;
      void push(const T&amp;);
      void pop(T&amp;);
      void head(T&amp;) const;
      void print();
      int length();
  
      private:
      elem_q&lt;T&gt; *front;
      elem_q&lt;T&gt; *rear;
  
      void copyQueue(const Queue&lt;T&gt;);
      void deleteQueue();
  };
  
  template &lt;typename T&gt;
  Queue&lt;T&gt;::Queue()
  {
  front = rear = NULL;
  }
  
  template &lt;typename T&gt;
  Queue&lt;T&gt;::~Queue()
  {
    deleteQueue();
  }
  
  template &lt;typename T&gt;
  Queue&lt;T&gt;::Queue(const Queue&lt;T&gt;&amp; r)
  {
  copyQueue(r);
  }
  
  template &lt;typename T&gt;
  Queue&lt;T&gt;&amp; Queue&lt;T&gt;::operator=(const Queue&lt;T&gt;&amp; r)
  {
  if(this != &amp;r)
  {
      deleteQueue();
      copyQueue(r);
  }
  return *this;
  }
  
  template &lt;typename T&gt;
  void Queue&lt;T&gt;::copyQueue(const Queue&lt;T&gt; r)
  {
  front = rear = NULL;
  elem_q&lt;T&gt; *p = r.front;
  while(p)
  {
      push(p-&gt;inf);
      p = p-&gt;link;
  }
  }
  
  template &lt;typename T&gt;
  void Queue&lt;T&gt;::deleteQueue()
  {
  T x;
  while (!empty())
  {
      pop(x);
  }
  }
  
  template &lt;typename T&gt;
  bool Queue&lt;T&gt;::empty() const
  {
  return rear == NULL;
  }
  
  template &lt;typename T&gt;
  void Queue&lt;T&gt;::push(const T&amp; x)
  {
  elem_q&lt;T&gt; *p = new elem_q&lt;T&gt;;
  p-&gt;inf = x;
  p-&gt;link = NULL;
  if (rear) rear-&gt;link = p;
  else front = p;
  rear = p;
  }
  
  template &lt;typename T&gt;
  void Queue&lt;T&gt;::pop(T&amp; x)
  {
  if(empty())
  {
      cout&lt;&lt;"The queue is empty.\n";
  }
  else
  {
      elem_q&lt;T&gt; *q = front;
      x = q-&gt;inf;
      if (q == rear)
      {
          rear = NULL;
          front = NULL;
      }
      else front = q-&gt;link;
      delete q;
  }
  }
  
  template &lt;typename T&gt;
  void Queue&lt;T&gt;::head(T&amp; x) const
  {
  if(empty())
  {
      cout&lt;&lt;"The queue is empty.\n";
  }
  else
  {
      x = front-&gt;inf;
  }
  }
  
  template &lt;typename T&gt;
  void Queue&lt;T&gt;::print()
  {
  T x;
  while(!empty())
  {
      pop(x);
      cout&lt;&lt;x&lt;&lt;" ";
  }
  cout&lt;&lt;endl;
  }
  
  template &lt;typename T&gt;
  int Queue&lt;T&gt;::length()
  {
  T x;
  int n = 0;
  while(!empty())
  {
      pop(x);
      n++;
  }
  return n;
  }
  template&lt;typename T&gt;
  void minqueue(Queue&lt;T&gt; q,T&amp; min,Queue&lt;T&gt;&amp; newq)
  {
  T x;
  q.pop(min);
  while (!q.empty())
  {
      q.pop(x);
      if (x &lt; min)
      {
          newq.push(min);
          min = x;
      }
      else newq.push(x);
  }
  
  }
  template&lt;typename T&gt;
  void sortQueue(Queue&lt;T&gt; q,Queue&lt;T&gt;&amp; newq)
  {
  while(!q.empty())
  {
      T min;
      Queue&lt;T&gt; q1;
      minqueue(q , min ,q1);
      newq.push(min);
      q = q1;
  }
  
  }
  template&lt;typename T&gt;
  Queue&lt;T&gt; merge(Queue&lt;T&gt; p,Queue&lt;T&gt; q,const T&amp; dummy)
  {
  p.push(dummy);
  q.push(dummy);
  Queue&lt;T&gt; r;
  T x,y;
  p.pop(x);
  q.pop(y);
  while (!p.empty() &amp;&amp; !q.empty())
      if (x &lt; y)
      {
          r.push(x);
          p.pop(x);
      }
      else
      {
          r.push(y);
          q.pop(y);
      }
  if (!p.empty())
      do
      {
          r.push(x);
          p.pop(x);
      }while (x != dummy);
  else 
      do
      {
          r.push(y);
          q.pop(y);
      }while (y != dummy);
      return r;
  }
  </code></pre>
  
  <p>How can i redefine operator &lt; and != because without them function minqueue,Sortqueue and merge do not work?Please help me...............................................                                                                                     </p>