1 #include <locale>
2 #include <vector>
3 #include <algorithm>
4 #include <strsafe.h>
5 using namespace std;
6
7 #define MAX_PATH 260
8
9 typedef struct tagITEM
10 {
11 int iNum;
12 wchar_t szName[MAX_PATH];
13 float fType;
14 unsigned operator==(const int num)
15 {
16 return (iNum==num);
17 }
18 } ITEM, *PITEM;
19
20 int main(int, char**)
21 {
22 int nums[10] = { 2, 5, 10, 50, 232, 42, 13, 895, 32, 11};
23 wchar_t* names[10] = { L"빨강", L"파랑", L"초록", L"노랑", L"분홍",
24 L"검정", L"주황", L"살색", L"연두", L"회색"};
25 float types[10] = { 12.4f, 53.1f, 50.2f, 203.2f, 302.4f, 12.1f, 33.0f, 3.1f, 40.1f, 22.0f };
26
27 vector<ITEM> mylist;
28
29 ITEM t;
30
31 for(int i=0; i<10; i++)
32 {
33 t.iNum = nums[i];
34 StringCchCopyW(t.szName, MAX_PATH, names[i]);
35 t.fType = types[i];
36 mylist.push_back(t);
37 }
38
39
40 setlocale(LC_ALL, "korean");
41
42 for(int i=0; i<10; i++)
43 {
44 t = mylist[i];
45 printf("%d %d %S %f\n", i+1, t.iNum, t.szName, t.fType);
46 }
47
48 vector<ITEM>::iterator pos;
49
50 pos = std::find(mylist.begin(), mylist.end(), 42);
51
52 printf("\nFinding num is 42 ...\n\n");
53
54 if ( pos == mylist.end() )
55 {
56 printf("No item\n");
57 }
58 else
59 {
60 printf("Found %d %S %f\n", (*pos).iNum, (*pos).szName, (*pos).fType );
61 }
62
63 mylist.clear();
64
65 return 0;
66 }
업데이트가 필요함 -_ㅡ;