title: How to insert elements from a structure into a min heap priority queue
body: <p>I am making a file compressor using Huffman Algorithm in C++. I have calculated the character frequency, but now I am having difficulty in pushing it into a min heap priority queue. I want to sort the inserted elements by frequency.  Every time I execute the code, it gives the error:</p>
  <pre><code>Error C2676 binary '&gt;': 'const _Ty' does not define this operator or a conversion to a type acceptable to the predefined operator
  </code></pre>
  <p>I have tried almost every way mentioned on this website, yet I still cannot get rid of this error.</p>
  <p>Here is my code:</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  #include&lt;queue&gt;
  #include&lt;vector&gt;
  #include&lt;functional&gt;
  #include&lt;algorithm&gt;
  
  using namespace std;
  
  struct node
  {
      char c; //character in the string
      int f; //Frequency of character in the string
      node* next;
      node* left, * right; //left and right child of binary tree respectively
  
      node()
      {
          f = 0;
          left = NULL;
          right = NULL;
          c = NULL;
          next = NULL;    
      }
  
      bool operator&gt;(const node&amp; a)
      {
          return a.f &gt; f;
      }
  
      };
  
  class Huffman
  {
      string text; //The text that will be encoded
      priority_queue &lt;node&gt; pq;
  public:
      Huffman()
      {
          
      }
  
      void StringInput()
      {
          cout &lt;&lt; &quot;Enter the string you want to encode:&quot;;
          getline(cin, text);
      }
  
      //Function which will calculate the frequency of characters in the string entered by the user
      void CharacterFrequency()
  {
          
          for (int i = 0; i &lt; text.length(); i++)
          {
              int sum = 0;
              for (int j = 0; j &lt; text.length(); j++)
              {
  
                  if (j &lt; i and text[i] == text[j])
                  {
                      break;
                  }
  
  
                      if (text[i] == text[j])
                      {
                          sum++;
                      } 
                      
                      
                  
              }
  
              if (sum != 0)
              {
                  PriorityQueue(text[i], sum);
              }
          }
  }
  
  void PriorityQueue(char ch, int freq)
      {
          
          node n;
          n.c = ch;
          n.f = freq;
          pq.push(n);
          
  
          
      }
  
  
  };
  
  int main()
  {
      Huffman obj;
      obj.StringInput();
      obj.CharacterFrequency();
      
      return 0;
  }
  </code></pre>
  <p>I will be grateful for any help in this regard.</p>