-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.cpp
More file actions
59 lines (52 loc) · 979 Bytes
/
set.cpp
File metadata and controls
59 lines (52 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* =====================================================================================
*
* Filename: set.cpp
*
* Description:
*
* Version: 1.0
* Created: 06/20/2011 05:16:48 PM
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Company:
*
* =====================================================================================
*/
#include <iostream>
#include <set>
class pointer
{
public:
pointer(int tok)
{
i=tok;
}
bool operator<( const pointer& p) const
{
return i<p.i;
}
int i;
};
int main(int argc,char**argv)
{
std::set<pointer> pset;
pointer *p= new pointer(1);
pset.insert(*p);
p= new pointer(2);
pset.insert(*p);
p= new pointer(1);
std::set<pointer>::iterator it;
it= pset.find(*p);
if(it!=pset.end())
{
std::cout<<"find 1"<<std::endl;
}
else
{
std::cout<<"find end()"<<std::endl;
}
return 0;
}