类模板
一、类模板写法 1. 声明和定义写在一起 template<class T> class Person{ public: Person(T age){ this->m_age = age; } void Show(){ cout << this->m_age << endl; } private: T m_age; }; int main() { Person<int> p(20); p.Show(); cout << p << endl; printP(p); return 0; } 2. 声明和定义分开写,但在同一文件中 template<class T> class Person{ public: Person(T age); void Show(); private: T m_age; }; template<class T> Person<T>::Person(T age){ this->m_age = age; } template<class T> void Person<T>::Show(){ cout << this->m_age << endl; } int main() { Person<int> p(20); p....