title: Why can't I make a priority queue of type struct objects?
body: <p>So I kinda know that I can't make a priority queue with type struct but I don't exactly understand the reason why? I mean if you can create template classes to make your own type, why would a struct be any different?</p>
  
  <p>This is what my code looks like in main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;queue&gt;
  #include &lt;string&gt;
  
  struct DATA {
      std::string key;
      int data;
  };
  
  int main() {
      std::priority_queue&lt;DATA&gt; priorityQ;
      DATA newItem;
      newItem.key = "apples";
      newItem.data = 3;
      priorityQ.push(newItem);
      std::cout &lt;&lt; priorityQ.top().key &lt;&lt; std::endl;
  
      std::cout &lt;&lt; "Press the 'ENTER' key to continue...";
      std::cin.get();
  
      return 0;
  }
  </code></pre>
  
  <p>The error come up with:</p>
  
  <pre><code>Error   C2678   binary '&lt;': no operator found which takes a left-hand
  operand of type 'const DATA' (or there is no acceptable conversion)
  TestProj    c:\program files (x86)\microsoft visual studio 
  14.0\vc\include\xstddef    Line: 240    
  </code></pre>
  
  <p>I tried making this operator overload:</p>
  
  <pre><code>bool operator&lt;(const DATA&amp; a, const DATA&amp; b) {
      return a.data &gt; b.data;
  }
  </code></pre>
  
  <p>But it still does not compile...</p>
  
  <p>My question is: is it possible to put struct objects in priority queues and , and if not, why?</p>