title: How to implement sorting method for a c++ priority_queue with pointers
body: <p>My priority queue declared as:</p>
  
  <pre><code>std::priority_queue&lt;*MyClass&gt; queue;
  
  class MyClass {
      bool operator&lt;( const MyClass* m ) const;
  }
  </code></pre>
  
  <p>is not sorting the items in the queue.</p>
  
  <p>What is wrong? I would not like to implement a different (Compare) class.</p>
  
  <p><strong>Answer summary:</strong></p>
  
  <p>The problem is, the pointer addresses are sorted. The only way to avoid this is a class that 'compares the pointers'.</p>
  
  <p>Now implemented as:</p>
  
  <pre><code>std::priority_queue&lt;*MyClass, vector&lt;*MyClass&gt;, MyClass::CompStr &gt; queue;
  
  class MyClass {
      struct CompStr {
          bool operator()(MyClass* m1, MyClass* m2);
      }
  }
  </code></pre>