Code: Select all
#include <set>
#include <iostream>
using namespace std;
class Test {
public :
int x, y;
};
class comp {
public:
int operator () (Test a, Test b)
{
if (a.x < b.x || (a.x == b.x && a.y < b.y)) return 1;
return 0;
}
};
int main()
{
set<Test, comp> s;
Test temp;
temp.x = 1; temp.y = 2;
s.insert(temp);
temp.x = 2; temp.y = 2;
s.insert(temp);
temp.x = 2; temp.y = 1;
s.insert(temp);
temp.x = 1; temp.y = 2;
set<Test, comp>::iterator i = s.find(temp);
if ( i != s.end() ) cout << "Yes\n"; else cout << "No\n";
return 0;
}