title: Why is STL priority queue incorrectly sorrting my class objects
body: <p>I have overloaded the <code>&lt;</code> operator as shown but every time the program is run my class objects are sorted seemingly randomly.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class Node
  {
  int decimal_value
  public:
      Node(int decimal) : decimal_value(decimal)
      {}
      friend bool operator&lt;(const Node&amp; p1, const Node&amp; p2);
  };
  
   bool operator&lt;(const Node&amp; p1, const Node&amp; p2)
  {
      return p1.decimal_value &lt; p2.decimal_value;
  }
  
  int main()
  {
      Node* n1= new Node(5);
      Node* n2 = new Node(4);
  
      priority_queue&lt;Node*&gt; my_q;
      my_q.push(n1);
      my_q.push(n2);
  }
  </code></pre>
  
  <p>Is it possibly due to my use of pointers to Nodes rather than Nodes themselves? And if so how can I fix this?</p>