#include <afxtempl.h> typedef struct xyz { double x; double y; double z; }XYZ; struct ltstr { bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; } }; #include <comdef.h> BOOL CListTestDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon
typedef struct xyz
{
double x;
double y;
double z;
}XYZ;
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
#include <comdef.h>
BOOL CListTestDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
{
vector<int*> vector1;
int *p=NULL;
p=new int;
*p=5;
vector1.push_back(p);
p=new int;
*p=6;
vector1.push_back(p);
p=vector1[0];
delete p;
p=vector1[1];
delete p;
vector1.clear();
}
if(0)
{
list<int*> list1;
list<int*>::iterator iter;
int *p=NULL;
p=new int;
*p=5;
list1.insert(list1.end(),p);
p=new int;
*p=6;
list1.insert(list1.end(),p);
for(iter=list1.begin();iter!=list1.end();iter++)
{
delete(*iter);
}
list1.clear();
}
if(0)
{
map<const char*, int, ltstr> months;
months["january"] = 31;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
months["may"] = 31;
months["june"] = 30;
months["july"] = 31;
months["august"] = 31;
months["september"] = 30;
months["october"] = 31;
months["november"] = 30;
months["december"] = 31;
map<const char*, int, ltstr>::size_type st = months.size();
int i=months["january"];
i=months["february"];
months.clear();
}
// TODO: Add extra initialization here
if(0)
{
char str[256];
CTypedPtrList <CPtrList, XYZ*> list;
//添加
XYZ *pxyz=new XYZ;
pxyz->x=0;
pxyz->y=1;
pxyz->z=2;
list.AddTail(pxyz);
pxyz=new XYZ;
pxyz->x=3;
pxyz->y=4;
pxyz->z=5;
list.AddTail(pxyz);
//遍历
POSITION pos;
pos=list.GetHeadPosition();
while(pos)
{
pxyz=list.GetNext(pos);
//可以修改其中的值
pxyz->x=5;
sprintf(str,"%f %f %f",pxyz->x,pxyz->y,pxyz->z);
}
//删除
pos=list.GetHeadPosition();
while(pos)
{
pxyz=list.GetNext(pos);
delete pxyz;
}
list.RemoveAll();
}
if(0)
{
CMapStringToPtr StrMap;
int *p=new int;
*p=10;
StrMap.SetAt("bluebohe",p);
p=new int;
*p=11;
StrMap.SetAt("vcforever",p);
p=NULL;
POSITION pos=StrMap.GetStartPosition();
while(pos)
{
CString str;
StrMap.GetNextAssoc(pos,str,(void *&)p);
if(p!=NULL)
{
delete p;
p=NULL;
}
}
StrMap.RemoveAll();
}
return TRUE; // return TRUE unless you set the focus to a control
}