#include <iostream>
#include <string>
#include <fstream>
using namespace std;
template<class T1,class T2>
class Person
{
public:
Person(T1 name,T2 age)
{
this->name=name;
this->age=age;
}
void showPerson()
{
cout<<"name:"<<this->name<<endl;
cout<<"age:"<<this->age<<endl;
}
private:
T1 name;
T2 age;
};
void printPerson1(Person<string,int> &p)
{
p.showPerson();
}
template<class T1,class T2>
void printPerson2(Person<T1,T2> &p)
{
p.showPerson();
cout<<":"<<typeid(T1).name()<<endl;
cout<<":"<<typeid(T2).name()<<endl;
}
template<class T>
void printPerson3(T &p)
{
p.showPerson();
cout<<":"<<typeid(T).name()<<endl;
}
void test03()
{
Person<string,int>p("Tom",10);
printPerson3(p);
}
void test01()
{
Person<string,int>p("Tom",10);
printPerson2(p);
}
int main()
{
test03();
system("pause");
}