类模板与继承

#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
posted @ 2022-07-21 07:53  thomas_blog  阅读(27)  评论(0编辑  收藏  举报