Basically, I have the following code: a struct with a quicksort method using cmp1 for comparing. I would like to add a parameter to qsort so I can use it with either cmp1 or cmp2.
struct X {
int *l;
int *r;
int cmp1(int *p, int *q) { return p - q; }
int cmp2(int *p, int *q) { return *p - *q; }
void qsort(int *l, int *r) {
int *i = l;
int *j = r;
int *x = ...;
do {
while (cmp1(i, x) < 0) i++;
...
}
...
}
inlinevoid Sort() {
...
qsort(l, r);
}
};
I have tried several things from articals all over the web for the last hour but none compiled (with VS 2008), so any help would be appreciated.
Please help, I don't want to end up with two qsort methods - one for cmp1 and the other one for cmp2...