![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 伯勞鳥 ![]()
![]() |
GA.h: 而我的 fitness_sort() 是要對populations這個向量中的fitness_1變數做排序,卻一直出現下列錯誤訊息: C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\bits\predefined_ops.h|121|error: must use '.*' or '->*' to call pointer-to-member function in '((__gnu_cxx::__ops::_Iter_comp_iter<bool (GA::*)(const InDividual&, const InDividual&)>*)this)->__gnu_cxx::__ops::_Iter_comp_iter<bool (GA::*)(const InDividual&, const InDividual&)>::_M_comp (...)', e.g. '(... ->* ((__gnu_cxx::__ops::_Iter_comp_iter<bool (GA::*)(const InDividual&, const InDividual&)>*)this)->__gnu_cxx::__ops::_Iter_comp_iter<bool (GA::*)(const InDividual&, const InDividual&)>::_M_comp) (...)'| 感覺是在comp()函數那邊出問題,應該如何改呢? 我的GA.cpp中的population_sort()成員函數如下: |
1樓
最有價值解答
Raymond ![]() |
GA::comp 必須是個 static 成員函式:
在呼叫函式 std::sort() 時, 第三個參數應該改成 &GA::comp: 建議不要用 using namespace std, 儘量習慣用 std:: 來前綴 C++ 標準函式庫裡的名字.
本篇文章回覆於2016-08-15 22:09
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
2樓
作者回應
伯勞鳥 ![]() |
感謝 Raymond 大大的解答,謝謝!!
本篇文章回覆於2016-09-03 01:21
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
回覆 |
如要回應,請先登入. |