# re: C++基础知识: list结构体排序方法(一) 回复 更多评论
2010-03-06 22:50 by luckycat
@小苏
在阅读下面的分析之前,希望你对"C++对象的内部布局"有一定的了解.
既然你也发现了内存泄漏的情况,那么你再用下面的测试代码运行一下:
#include "Windows.h"
#include
#include
#include
using namespace std;
typedef unsigned int UINT32;
typedef unsigned short UINT16;
typedef struct structMan
{
UINT32 sexType; //ENUM_SEXY_TYPE
UINT16 usAge;
string strName;
string strAddress;
bool operator < (const structMan &man) const
{
return usAge < man.usAge;
}
bool operator > (const structMan &man) const
{
return usAge > man.usAge;
}
}MAN;
int main( int argc , char *argv[] )
{
while( true )
{