64,676
社区成员
发帖
与我相关
我的任务
分享
#include<map>
#include<algorithm>
#include<iterator>
#include<string>
#include<iostream>
using namespace std;
typedef map<string, int> months_type;
namespace std
{
template <class First,class Second>
ostream& operator<<(ostream& out, const pair<First,Second> &p)
{
cout<<p.first<<" has "<<p.second<<" days";
return out;
}
ostream& operator<<(ostream& out,const months_type & l)
{
copy(l.begin(), l.end(), ostream_iterator<months_type::value_type>(out, ";\n"));
return out;
}
}
void main()
{
months_type months;
typedef months_type::value_type value_type;
months.insert(value_type(string("January"),31));
months.insert(value_type(string("February"),28));
months.insert(value_type(string("April"),30));
months.insert(value_type(string("March"),31));
cout<<months<<endl;
}