İ wrote bubble sort function,i want to run this function each type and class for example class Collos.but it does not compile.i wrote comparator each type and class but not worked. where is the problem.
Code:
class Collos{
public:
int collo;
int wottlo;
};
void sort(void *newarray,size_t total_elems ,int (* comparator) (const void *, const void *) ){
void *temp;
for ( int i = 0 ; i < total_elems-1 ; ++i){
for ( int j = 0; j <total_elems-i-1 ; ++j ){
if( (*comparator)( *(void *)newarray[j],*(void*)newarray[j+1] )){
*temp = *newarray[j];
*newarray[j] = *newarray[j+1];
*newarray[j+1] = * temp;
}
}
}
}