64,649
社区成员
发帖
与我相关
我的任务
分享
sort(ms, ms+5);
#include <algorithm>
#include <vector>
using namespace std;
class myclass
{
public:
CString str;
bool operator < (const myclass& ob)
{
return str < ob.str;
}
myclass()
{
str = "";
}
myclass(const myclass& ob)
{
str = ob.str;
}
myclass(const char* pstr)
{
str = pstr;
}
myclass& operator = (const char* pstr)
{
str = pstr;
return *this;
}
};
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
myclass ar;
vector<myclass> v;
ar = "mnsh";
v.push_back(ar);
ar = "efgh";
v.push_back(ar);
ar = "abce";
v.push_back(ar);
ar = "abmn";
v.push_back(ar);
ar = "strg";
v.push_back(ar);
std::sort(v.begin(), v.end());
return 0;
}