#pragma once
#include <iostream>
#include <string>
using namespace std;
template<class T1, class T2>
class Person
{
public:
Person(T1 name,T2 age);
void showPerson();
T1 m_Name;
T2 m_Age;
};
#include "pch.h"
#include "Person.h"
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>::showPerson()
{
cout << "姓名:" << this->m_Name << " 年龄: " << this->m_Age << endl;
}
#include <iostream>
#include <string>
#include "Person.h"
#include "Person.cpp"
//注意头文件:string 和 string.h 的区别;
using namespace std;
//类模板的分文件编写及问题及解决
//建议模板不要做分文件编写,写到一个类中