我有一個關於std :: sort算法的問題。這裏是我的測試代碼:std ::排序沒有函子
struct MyTest
{
int m_first;
int m_second;
MyTest(int first = 0, int second = 0) : m_first(first), m_second(second)
{
}
};
int main(int argc,char *argv[])
{
std::vector<MyTest> myVec;
for(int i = 0; i < 10; ++i)
{
myVec.push_back(MyTest(i, i + 1));
}
//Sort the vector in descending order on m_first without using stand alone function or functors
return 0;
}
是否有可能在可變m_first
矢量進行排序,而無需使用任何獨立的函數或仿函數?另外,請注意,我沒有使用提升。
操作員應該只帶一個參數並與「this」進行比較。 – sth 2009-06-01 07:58:02
是的,修好了,謝謝! – 2009-06-01 08:03:29