title: Priority queue with Pointers and Comparator C++
body: <p>I just started to learn C++, Half of the time I don't know what am I doing, spend hours and hours searching on Google and blindly put codes inside my project, this might be a basic question, but I just can't seems to get it right.</p>
  
  <p><strong>This is the requirement</strong> of my assignment, I need to have these:</p>
  
  <p><strong>in the Edge class:</strong> </p>
  
  <pre><code>public:
  bool operator()(Edge*, Edge*)
  </code></pre>
  
  <p><strong>in the Graph class:</strong></p>
  
  <pre><code>private:
  priority_queue&lt;Edge*, vector&lt;Edge*&gt;, Edge&gt; edges
  </code></pre>
  
  <p><strong>I have problem declaring the priority_queue. Details:</strong> </p>
  
  <p>If I directly use these, the edge class will give me an error of "must have an argument of class", I understand that I can't overload two pointers into the bool operator, so <strong>this is what I have tried:</strong> </p>
  
  <p><strong>in the Edge.cpp:</strong></p>
  
  <pre><code>#include "Edge.h"
  using namespace std;
  
  Edge::Edge(Vertex* s, Vertex* d, double w)
  {
      source = s;
      destination = d;
      weight = w;
  }
  
  double Edge::getWeight()
  {
      return weight;
  }
  
  struct CompareWeight : public std::binary_function&lt;Edge*, Edge*, bool&gt;
  {
      bool operator()(Edge* e1,Edge* e2)
      {
          double w1 = e1-&gt;getWeight();
          double w2 = e2-&gt;getWeight();
  
          if(w1&gt;w2){
              return true;
          }
          else {
              return false;
          }
      }
  };
  </code></pre>
  
  <p>^ I am not even sure about putting struct inside the class is correct or not, Plus in this cause I don't know what to put inside my Edge.h file.</p>
  
  <p><strong>in the Edge.h:</strong> </p>
  
  <pre><code>#include "Vertex.h"
  class Edge
  {
      public:
          Edge(Vertex*, Vertex*, double);
          double getWeight();
          friend struct CompareWeight; // ??? does not seems right
      private:
          Vertex* source;
          Vertex* destination;
          double weight;
  }
  </code></pre>
  
  <p>As for the Graph class is where the real problem is, I can't even get pass declaring the priority queue without getting an error. </p>
  
  <p><strong>in the Graph.h</strong> </p>
  
  <pre><code>#include "Vertex.h"
  #include "Edge.h"
  #include &lt;vector&gt;
  #include &lt;queue&gt;
  
  class Graph
  {
      public:
          ...
  
      private:
          priority_queue&lt;Edge*, vector&lt;Edge*&gt;, Edge&gt; edges
          // This give pointer error: no match for call to '(Edge) (Edge*&amp;, Edge*&amp;)'
  }
  </code></pre>
  
  <p>second attempt: </p>
  
  <pre><code>// same as above
  private:
      priority_queue&lt;Edge*, vector&lt;Edge*&gt;, CompareWeight&gt; edges
      // This give error: 'CompareWeight' not declared in this scope
  </code></pre>
  
  <p>I don't know why for the first error, but the second error I understood it clearly, but I don't know how to fix it, should I put something in front of CompareWeight? I tried many things, nothing work. </p>
  
  <p>Any help will be greatly appreciated! otherwise I would probably just fail this course.
  First time asking in stackoverflow, if I did anything wrong please tell me. </p>