title: c++ - Priority Queue - How does it work internally?
body: <p>Say I have this declaration of a priority queue:</p>
  
  <pre><code>    struct orderByRewards{
  
      bool operator() (pair&lt;int,pair&lt;int,int&gt; &gt; a, pair&lt;int, pair&lt;int, int&gt; &gt; b){
          return a.first &lt; b.first;
      }
  };
  
  priority_queue&lt;pair&lt;int,pair&lt;int,int&gt; &gt;, vector&lt;pair&lt;int,pair&lt;int,int&gt; &gt; &gt;, orderByRewards&gt; Q;
  </code></pre>
  
  <p>I was wondering if anybody could take their time and explain me how does the compiler interpret the compare class.</p>
  
  <ul>
  <li>Why do I need to overload the () operator ? </li>
  <li>Also, where's the () operator used in its comparing process ? </li>
  </ul>
  
  <p>It feels a little weird, especially since I am not really comfortable with templates and all OOP concepts.</p>
  
  <p>Why do we need to declare the type of a single object and the container type ?</p>