#include<iostream>
#include<string>
using namespace std;
//类模板成员函数类外实现
template<class T1,class T2>
class person
{
public:
person(T1 name, T2 age);
/*{
this->m_Name = name;
this->m_Age = age;
}*/
void showperson();
/*{
cout << "姓名;" << this->m_Name << " 性别: " << this->m_Age << endl;
}*/
T1 m_Name;
T2 m_Age;
};
//构造函数类外实现
template<class T1,class T2> //要加模板的参数列表 和作用域
person<T1,T2>::person(T1 name, T2 age)//person::person(T1 name, T2 age) 普通函数类外实现写法
{
this->m_Name = name;
this->m_Age = age;
}
//成员函数类外实现
template<class T1, class T2>
void person<T1, T2>::showperson()
{
cout << "姓名;" << this->m_Name << " 性别: " << this->m_Age << endl;
}
void test01()
{
person<string,int>p("tom", 20);
p.showperson();
}
void test02()
{
}
void test03()
{
}
int main()
{
test01();
//test02();
//test03();
system("pause");//按任意键继续
return 0;//关闭程序
}