Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SP-0402.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "SP-0402.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // The one and only application object
- CWinApp theApp;
- using namespace std;
- int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
- {
- int nRetCode = 0;
- HMODULE hModule = ::GetModuleHandle(NULL);
- if (hModule != NULL)
- {
- // initialize MFC and print and error on failure
- if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
- {
- // TODO: change error code to suit your needs
- _tprintf(_T("Fatal Error: MFC initialization failed\n"));
- nRetCode = 1;
- }
- else
- {
- // TODO: code your application's behavior here.
- CList <int> list1;
- list1.AddTail(1);
- list1.AddTail(2);
- list1.AddTail(3);
- list1.AddTail(5);
- list1.AddTail(4);
- POSITION pos = list1.GetHeadPosition();
- for (int i = 0; i < list1.GetCount(); i++)
- {
- _tprintf_s(_T("%d\r\n"), (int)list1.GetNext(pos));
- }
- CPtrList list2;
- list2.AddTail(new CPoint(1, 1));
- list2.AddTail(new CPoint(1, 2));
- list2.AddTail(new CPoint(1, 1));
- for (pos = list2.GetHeadPosition(); pos != NULL;)
- {
- CPoint * p = (CPoint *) list2.GetNext(pos);
- _tprintf_s(_T("%d %d\r\n"), p->x, p->y);
- }
- /*
- */
- CMapStringToOb myMap; // A nontemplate collection class
- CPerson myPerson;
- myMap.SetAt(_T("Bill"), &myPerson);
- POSITION pos = myMap.GetStartPosition();
- while (pos != NULL)
- {
- CPerson* pPerson;
- CString string;
- // Gets key (string) and value (pPerson)
- myMap.GetNextAssoc(pos, string,
- (CObject*&)pPerson);
- ASSERT(pPerson->IsKindOf(
- RUNTIME_CLASS(CPerson)));
- // Use string and pPerson
- }
- }
- }
- else
- {
- // TODO: change error code to suit your needs
- _tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
- nRetCode = 1;
- }
- return nRetCode;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement