1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{ return strcmp(s1, s2) < 0; }
};
int main( int argc, char *argv[] )
{
const char* a[] = { "Gray", "Pete", "Oggy", "Philip", "JAF", "Simon", "Nick",
"Elliott", "Roy", "David", "Tony", "Nigel" };
const char* b[] = { "Sandy", "John", "Andrzej", "Rob", "Phil", "Happy",
"Elliott", "Roy", "David", "Tony", "Nigel" };
set<const char*, ltstr> A(a, a + sizeof(a)/sizeof(a[0]) );
set<const char*, ltstr> B(b, b + sizeof(b)/sizeof(b[0]) );
set<const char*, ltstr> C;
cout << "Set A: ";
copy(A.begin(), A.end(), ostream_iterator<const char*, char>(cout, " ") ); |
Partager