【发布时间】:2015-05-08 03:01:01
【问题描述】:
假设我有这个类:
class cat
{
private:
int age;
string name;
public:
cat();
~cat();
void set_age(int a) { age = a; }
void set_name(string n) { name = n; }
int get_age() { return age; }
string get_name() { return name; }
}
我有一个未排序的向量,其中包含 cat 类的对象,称为 vector<cat> cats 或其他东西。我将如何使用算法 STL 按名称对它们进行排序?
【问题讨论】:
-
你有什么不明白的地方?你读过一些文档吗?网络上肯定有一百万个例子。
-
问题一经发布并收集到答案,请不要从根本上改变问题。