语法
- template
- 类
#include<iostream>
using namespace std;
//类模板
template<class Name,class Age>
class person
{
public:
Name name;
Age age;
person(Name m_name, Age m_age)
{
this->name = m_name;
this->age = m_age;
}
void print()
{
cout << "name:" << this->name << "age:" << this->age<<endl;
}
};
int main()
{
person<string, int>p1("送一", 51);
p1.print();
system("pause");
return 0;
}