我有簡單的C++類那裏我需要做的排序陣列,這裏是我有:C++快速排序與指針錯誤的函數(COMPAR)
void GameController::sortArray(CCArray *&sameRowGemArray)
{
qsort(sameRowGemArray->data->arr, sameRowGemArray->data->num, sizeof(long), &GameController::comperator);
}
int GameController::comperator(const void * a, const void * b)
{
/*
..didn't implement logic first i need it to compile
*/
return 1;
}
但即時得到編譯錯誤說:
error C2664: 'qsort' : cannot convert parameter 4 from 'int (__thiscall GameController::*)(const void *,const void *)' to 'int (__cdecl *)(const void *,const void *)'
是不是它指針功能在哪裏是comperator?
感謝您的回答! – user63898
https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types –