#include <iostream>
#include <string>
using namespace std;
template<class T1, class T2>
class Students10{
public:
T1 m_name;
T2 m_age;
Students10(T1 name, T2 age); // 类内声明 类外实现
// {
// this->m_name = name;
// this->m_age = age;
// }
void show();
// {
// cout << "姓名: " << this->m_name << "年龄: " << this->m_age << endl;
// }
};
// 无论函数中是否用到T1、T2 都要写在类名后面的尖括号中
template<class T1, class T2>
Students10<T1,T2>::Students10(T1 name, T2 age){
this->m_name = name;
this->m_age = age;
}
template<class T1, class T2>
void Students10<T1,T2>::show(){
cout << "姓名: " << this->m_name << "年龄: " << this->m_age << endl;
}
int main()
{
Students10<string, int> stu("张阿三",18);
stu.show();
return 0;
}