类模板成员函数类外实现
作者:互联网
#include <iostream>
template<class typeName>
class Person
{
public:
Person(typeName name);
void show();
protected:
typeName m_name;
};
template<class typeName>
Person<typeName>::Person(typeName name):
m_name(name)
{
}
template<class typeName>
void Person<typeName>::show()
{
std::cout << "name " << m_name << std::endl;
}
int main()
{
Person<std::string> p("furong");
p.show();
return 0;
}
标签:name,typeName,函数,show,Person,template,void,模板,类外 来源: https://www.cnblogs.com/zhangxuechao/p/16500579.html