CodeSarang.Com
Home | All categories Join | Login | 검색   

 

이미 선언된 구조체에 operator 추가하여 sort

등록자 : cpueblo (유광희), 2008-08-14
글수정 | 글삭제


struct TestStruct
{
public:
    char    Msg[128];

    bool operator<(const TestStruct& a) const
    {
        return strcmp(Msg, a.Msg) < 0;
    }
};

void function()
{
    std::vector list;
    sort(list.begin(), list.end());
}
struct TestStruct
{
public:
    char    Msg[128];

    bool operator<(const TestStruct& a) const
    {
        return strcmp(Msg, a.Msg) < 0;
    }
};

void function()
{
    std::vector list;
    sort(list.begin(), list.end());
}




글수정 | 글삭제
http://codesarang.com. mail to cpueblocpueblo.com