类模板与继承
#include <iostream>
#include <typeinfo>
template<class typeName>
class Person
{
public:
Person()
{
std::cout << "typeName数据类型 " << typeid(typeName).name() << std::endl;
}
protected:
typeName name;
};
template<class T>
class Student:public Person<T>
{
};
int main()
{
Student<std::string> s;
return 0;
}
$ ./a.out
typeName数据类型 NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE