#include <iostream>
#include <string>
using namespace std;
template <class T1,class T2>
class Pair
{
public:
T1 key;
T2 value;
Pair(T1 k,T2 v):key(k),value(v) { };
bool operator < ( const Pair<T1,T2> & p) const;
};
template<class T1,class T2>
bool Pair<T1,T2> ::operator < ( const Pair<T1,T2> & p) const
{
return value < p.value;
}
int main()
{
Pair<string,int>
student1
("Tom",19);
Pair<string,int> student2("jack",17);
cout<<"student1<student2="<<(student1<student2)<<endl;
return 0;
}
转载请注明原文地址:https://blackberry.8miu.com/read-32732.html