Listing 1 An attempt to use qsort in C++

#include <stdlib.h>

class A
   {
private:
struct DataType
   {
   double x, y;
   } *data;
   int size;
public:
   A();
   A(int n, double *x, double *y);
   sort();
   }

A::A() { } // Code Omitted

A::A(int n, double *x, double *y) { } // Code Omitted

A::sort()
   {
   qsort(data, size, sizeof(DataType), compare_function);
   }

int compare_function(const void *a, const void *b)
   {
   const DataType *first = (DataType *) a;
   const DataType *second = (DataType *) b;
   if ( first->x > second->x )
   return -1;
   else if ( first->x < second->x )
       return 1;
   else
       return 0;
   }

// End of File