[问题] std::list sort()

楼主: hardware (哈味)   2015-05-26 20:50:01
开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
G++ 4.1.3
问题(Question):
sort()
这个function是针对class的第一个成员做排序
有办法针对第二个成员吗?
程式码(Code):(请善用置底文网页, 记得排版)
class AAA
{
friend ostream &operator<<(ostream &, const AAA &);
public:
char x;
int y;
float z;
AAA();
AAA(const AAA &);
~AAA(){};
AAA &operator=(const AAA &rhs);
int operator==(const AAA &rhs) const;
int operator<(const AAA &rhs) const;
};
比如说
如果用 sort() 的话
会针对 char x 这个第一个成员作排序
有办法针对 int y做排序吗?
谢谢 另外想问说
std::list 有哪些函数可以使用哪里查的到呢?
比如 .push_front() .push_back() .merge() 等等
我在网络上查到的都是部份而已
谢谢
补充说明(Supplement):
作者: arsenefrog (柯蛙)   2015-05-26 20:54:00
C++不是有官方函数列表和说明吗
作者: Frozenmouse (*冰之鼠*)   2015-05-26 20:54:00
你的operator<实作?
作者: chchwy (mat)   2015-05-26 20:54:00
作者: fireslayer (fireslayer)   2015-05-26 21:35:00
自定义小于
作者: Littlechozy (キミに100%)   2015-05-26 22:23:00
有C++11的话喂一个lambda进去就好了

Links booklink

Contact Us: admin [ a t ] ucptt.com