我正試圖編寫一個函數來按照各種不同的屬性對自定義類對象的向量進行排序。按C++中的參數進行排序?
C++的排序的參考,在這裏找到:
http://www.cplusplus.com/reference/algorithm/sort/
說,你可以排序是這樣的:
std::sort (myvector.begin(), myvector.end(), myfunction);
我想做什麼就能做的是傳遞一個參數我的功能,除了從我的載體這樣兩個對象是這樣的:
std::sort (myvector.begin(), myvector.end(), myfunction(mode=7));
你知道這樣做嗎?
我對C++比較陌生,來自python,這很容易。
如何你使用'mode'嗎? – billz
更正,在這裏找到['std :: sort()'參考](http://en.cppreference.com/w/cpp/algorithm/sort):http://en.cppreference.com/w/ cpp/algorithm/sort – Johnsyweb
'mode = 7'是什麼意思?你將如何在[tag:python]中實現這一點? – Johnsyweb