hereの解を辿って、ペアのベクトルをソートしました。ペアのソートベクトル:一致する関数がありません
そして、私はコードで
linear_problem.h:275:
error: no matching function for call to
‘sort(std::vector<std::pair<int, double> >::iterator,
std::vector<std::pair<int, double> >::iterator, <unresolved overloaded
function type>)’
std::sort(data.begin(), data.end(), compareFunc);
クラスを取得するには、次のとおりです。
class Coefficients{
private:
std::vector<std::pair<int, double>> data;
public:
Coefficients(){}
bool compareFunc(const std::pair<int, double> &a, const std::pair<int, double> &b){
return a.first > b.first;
}
void sort(){
std::sort(data.begin(), data.end(), compareFunc);
}
};
コードはかなりの例のようなものですので、私は間違っている可能性が何の見当がつかない。
「compareFunc」は、「係数」のメンバー関数です。 'std :: sort'が持たない' Coefficients'型のオブジェクトでのみ呼び出すことができます。比較関数を 'Coefficients'の外に置くか、' static'にするのですか? – nwp