阅读背景:

错误:'void *'不是指针对象类型,什么是正确的解决方案?

来源:互联网 

I have the following code:

我有以下代码:

int partition(void* arr, int start, int end, bool(*cmp_f)(void*, void*),
              void(*swap_f)(void*, void*)) {
//    Point *pivot = &pts[end];
    int partition_index = start;

    for (int i = start; i < end; i++) {
        if (cmp_f(&arr[i], &arr[end])) {// <---------- Here
            swap_f(&arr[i], &arr[partition_index]);// <---------- Here
            partition_index++;
        }
    }
    swap_f(&arr[end], &arr[partition_index]);// <---------- Here
    return partition_index;
}
//------------------------------------------------------------------------------
void quick_sort(Point* pts, int start, int end, bool(*cmp_f)(void*, void*),
                void(*swap_f)(void*, void*)) {
    if (start < end) {//As long start is less than end we should arrange
        int pivot = partition(pts, start, end, cmp_f, swap_f);

        quick_sort(pts, start, pivot - 1, cmp_f, swap_f);
        quick_sort(pts, pivot + 1, end, cmp_f, swap_f);
    }
}
//------------------------------------------------------------------------------
int part



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: