#include <iostream>
#include <iterator>
#include <ctime>
#include <set>
#include <iterator>
#include <string>
using namespace std;
struct StringPtrLess:
public binary_function<string*, string*, bool> //使用这个基类的理由参见条款40
{
bool operator()(const string *ps1, const string *ps2) const
{
return *ps1 < *ps2;
}
};
int main()
{
set<string*, StringPtrLess> ssp;
ssp.insert(new string("Anteater"));
ssp.insert(new string("Wombat"));
ssp.insert(new string("Lemur"));
ssp.insert(new string("Penguin"));
for(set<string*, StringPtrLess>::const_iterator i = ssp.begin(); i != ssp.end(); ++i)
cout<<**i<<endl;
//编译通不过(类型不匹配)ostream_iterator<string>中参数为string,set为string*
//copy(ssp.begin(), ssp.end(), ostream_iterator<string>(cout, "/n"));
}