#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;
template <class T1,class T2>
class Person
{
private:
T1 m_name;
T2 m_age;
public:
template<class T1,class T2>
friend ostream& operator<<(ostream& os, Person<T1,T2>& p);
Person(T1 name, T2 age);
void show();
};
template<class T1, class T2>
ostream& operator<<(ostream& os, Person<T1,T2>& p)
{
os<< p.m_name << " is " << p.m_age << " years old" << endl;
return os;
}
template<class T1,class T2>
Person<T1,T2>::Person(T1 name, T2 age)
{
this->m_name = name;
this->m_age = age;
}
template<class T1,class T2>
void Person<T1,T2>::show()
{
cout << m_name << " is " << m_age << " years old" << endl;
}
void test01()
{
Person<string,int> p("LiPing", 19);
/*p.show();*/
cout << p;
}
int main()
{
test01();
return 0;
}