title: C++ STL priority queue of Node Pointers
body: <p>I'm trying to implement a priority queue of <code>Node*</code>, where Node is a class I have defined myself.  I realized that having a priority queue of pointers would mean that it would sort based on the address, rather than the value that the Node held, and so I searched through quite a few discussion forums to find a solution that would allow me to specify how to sort the Node objects in the priority queue; most agree that you need to write a struct that contains a function that takes as arguments 2 Node objects and returns the desired comparison.  The following is my Node class (abbreviated) and the struct I wrote to compare 2 Node objects, which are in the same header file:</p>
  
  <pre><code>class Node {
  
  public:
  
    ...
  
    int fValue() const { cerr &lt;&lt; fValue() &lt;&lt; endl; return c + h; };
  
    ...
  
  private:
    ...
    int c;
    int h;
  
    ...
  };                                                                                             
  
  struct CompareNode : public std::binary_function&lt;Node*, Node*, bool&gt;                                                                                     
  {
    bool operator()(const Node* lhs, const Node* rhs) const
    {
      return lhs-&gt;fValue() &lt; rhs-&gt;fValue();
    }
  }
  </code></pre>
  
  <p>I construct the priority queue as a member of another class in a different header file that includes the header file that contains the above definitions.  This class is abbreviated as follows:</p>
  
  <pre><code>class Astar {
  
  public:
  
    ...
  
  private:
  
    ...
    priority_queue&lt;Node*, vector&lt;Node*&gt;, CompareNode&gt; frontier;
  };
  </code></pre>
  
  <p>When I try to compile, I get this error:</p>
  
  <p>astar.h:28: error: multiple types in one declaration
  make: <em>*</em> [astar.o] Error 1</p>
  
  <p>where line 28 of astar.h corresponds to the end of the Astar class (<code>};</code>).</p>
  
  <p>Since this is the solution provided on most forums, I don't understand what's going on here.  Does anyone have any insight for me?</p>