error: called object type ‘int’ is not a function or function pointer

Your local variable mid is declared in the scope that is closer to the point of use, so it “shadows” the mid() function; the compiler thinks that you are trying to “call” an integer, which is invalid. Rename the local variable to fix this problem:

int midpoint;
if (hi > lo) {
    int i = lo + 1;
    int j = hi;
    int p = mid(lo, hi);
    swap(vec[lo], vec[p]);
    midpoint = vec[lo];
    ...
}

Note: you could also use ::mid(lo, hi) instead of renaming the variable, but that would confuse the readers of your program.

Leave a Comment