title: Invalid Operands to Binary Expression Person and Person
body: <p>I know this question has been asked before in similar circumstances, however I am new to C++ and cannot figure out what needs to be done or why it has to be done. Basically I am using a Person object that I created which has the variables name, age, height, and weight. I need to run a Quick Sort on the Person objects that I have created and sort them by age. </p>
  
  <p>Person Class:</p>
  
  <pre><code>class Person{
  private:
      string name;
      int age, height, weight;
  public:
  Person(string name = "empty", int age = 0, int height = 0, int weight = 0)
  {
      this-&gt;name = name;
      this-&gt;age = age;
      this-&gt;height = height;
      this-&gt;weight = weight;
  };
  </code></pre>
  
  <p>Quick Sort Method: </p>
  
  <pre><code>// Quick Sort
  void QuickSort(Person *A, int start, int end){
      if(start &lt; end){
          int p = partition(A, start, end);
          QuickSort(A, start, p - 1);
          QuickSort(A, p + 1, end);
      }
  }
  int partition(Person *A, int start, int end){
      Person pivot = A[end];
      int p = start;
      for(int i = start; i &lt;= end - 1; i++){
          if(A[i] &lt;= pivot){
              Person temp = A[i]; A[i] = A[p]; A[p] = temp;
              p++;
          }
      }
      Person temp = A[end]; A[end] = A[p]; A[p] = temp;
      return p;
  }
  </code></pre>
  
  <p>I am getting the error "Invalid operands to binary expression ('Person' and 'Person) on the line:</p>
  
  <pre><code>if(A[i] &lt;= pivot)
  </code></pre>
  
  <p>Any help would be appreciated because I have tried multiple things and I have looked it up but cannot get other suggestions to work in this situation. I would appreciate an explanation as to why I was getting this error too if possible. Thanks!</p>