Category : Files from Magazines
Archive   : CUJ9405.ZIP
Filename : PUGH01.LST

 
Output of file : PUGH01.LST contained in archive : CUJ9405.ZIP

#include

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;
}