So I have a assignment ask me to use randomized quick sort, and I found problems using function pointers.
The sort function is in rqs.cpp:
template <typename Item_Type>
void rqs_with_range(std::vector<Item_Type> &vec, int p, int q,
int (*cmp)(Item_Type, Item_Type));
Then in my cpp file, I have something like this:
class Table{
constructor....
vector< vector<string>* >* holder; // table
int compare_str(vector<string>* a, vector<string>* b) {
return a->at(compare_column) < b->at(compare_column) ? -1 :a->at(compare_column) == b->at(compare_column) ? 0 : 1;
}
void rqs{
rqs_with_range( (*holder) , 1, int(holder->size()-1), &Table::compare_str);
}
}
The compiler says I have error in function rqs, no matching function. my compare function is member function of Table, would it be the cause of problem?