For learning purpose, I want to create a pointer to the function void qsort (void* base, size_t num, size_t size, int (*compar)(const void*,const void*)) defined in cstdlib and use that pointer to function as argument for void* bsearch(const void* key, const void* base, size_t num, size_t size, int (*compar)(const void*,const void*)); defined in same library. My attempted code is this:
#include <iostream>
#include <cstdlib>
using namespace std;
class Student
{
public:
    Student(const char *_name, int _id) : name(_name), id(_id) {}
    int operator-(const Student &s) { return (id - s.id); }
private:
    const char *name;
    int id;
};
int compare_by_ID(const void *s1, const void *s2)
{
    return ( *(Student*)s1 - *(Student*)s2 ); 
}
typedef int (*compareFuncPtr)(const void *, const void *);
typedef void (*voidPtr)(void *, size_t, size_t, compareFuncPtr); /*how to use
                                                                 this pointer? 
                                                                 is it defined 
                                                                 correctly for 
                                                                 my purpose?*/
int main()
{
    Student s1("Bob", 8891);
    Student s2("Jack", 8845);
    Student s3("John", 8723);
    Student stdnts[] = {s1, s2, s3};
    compareFuncPtr compare;
    compare = compare_by_studentID;
    qsort(stdnts, 3, size0f(stdnts[0]), compare);    
    //voidPtr qsortPtr;
    //qsortPtr = ??? //to replace qsort(..) bellow:
    bsearch(&s3, qsort(stdnts, 3, sizeof(stdnts[0]), compare)); /*compile error:
                                                                 invalid use of
                                                             void expression.*/
}
How to replace arguments of bsearch(const void* key, const void* base, size_t num, size_t size,int (*compar)(const void*,const void*)) with a pointer to function? to use it like this: bsearch(key, pointerToFunction)
