title: c++ unordered_set Comparator function for a user-defined class
body: <p>I have something like this:</p>
  
  <pre><code>using namespace std;
  class QuadraticPrimeSolution
  {
      private:
          int a;
          int b;
          int numberOfPrimes;
          bool isPrime(int n, set&lt;int&gt; &amp;primeHash);
      public:
          QuadraticPrimeSolution(int a, int b):a(a),b(b),numberOfPrimes(0){};
          void calculateNumberOfPrimes(set&lt;int&gt; &amp;primeHash);
  
          int getNumberOfPrimes(){return numberOfPrimes;}
  };
  
  
  
  
  class QuadraticPrimeSolver
  {
      private:
          struct classcomp {
            bool operator() (QuadraticPrimeSolution&amp; lhs, QuadraticPrimeSolution&amp; rhs)
            {
              return lhs.getNumberOfPrimes()&gt;rhs.getNumberOfPrimes();
            }
          };
          set&lt;QuadraticPrimeSolution, classcomp&gt; solutions;
          set&lt;int&gt; primeHash;
          QuadraticPrimeSolution getMaxSolution();
          int a;
          int b;
  
      public:
  
          QuadraticPrimeSolver(int a, int b):a(a), b(b){};
          void solve();
  
  };
  
  bool QuadraticPrimeSolution::isPrime(int n, set&lt;int&gt; &amp;primeHash)
  {
      if(primeHash.empty())
      {
          primeHash.insert(n);
          return true;
      }
      for(auto it= primeHash.begin(); it!= primeHash.end(); it++)
      {
          if(n%(*it)==0)
          {
              return false;
          }
      }
      primeHash.insert(n);
      return true;
  }
  
  
  void QuadraticPrimeSolver::solve()
  {
      for(int i=(-1)*a; i&lt;=a; i++)
      {
          for(int j=(-1)*b; j&lt;=b; j++)
          {
              QuadraticPrimeSolution aSolution = new aSolution(i,j);
              aSolution.calculateNumberOfPrimes(primeHash);
              solutions.insert(aSolution);
          }
      }
  
  }
  int main()
  {
      QuadraticPrimeSolver QPS(0,40);
      QPS.solve();
  }
  </code></pre>
  
  <p>Basically what I am trying to do is compute and store each QuadraticPrimeSolution into a hash table in QuadraticPrimeSolver which I can then access later. </p>
  
  <p>My question is, is my comparator implementation correct? Right now compiler is complaining about my comparator, and the following line for inserting into a set.            </p>
  
  <pre><code>solutions.insert(aSolution);
  </code></pre>
  
  <p>Please help!</p>