c++类模板类外实现
作者:互联网
类外实现的时候要说明这是一个模板以及模板的通用变量
template<typename T1 ,typename T2> class person { public: person(T1 name,T2 age); void showperson(); T2 age; T1 name;
}; template<typename T1 ,typename T2> person<T1,T2>::person(T1 name,T2 age) { this->age = age; this->name = name; } template<typename T1 ,typename T2> void person<T1,T2>::showperson() { cout << this->age << this->name <<ebdl; }
template<typename T1 ,typename T2> class person { public: person(T1 name,T2 age); void showperson(); T2 age; T1 name;
}; template<typename T1 ,typename T2> person<T1,T2>::person(T1 name,T2 age) { this->age = age; this->name = name; } template<typename T1 ,typename T2> void person<T1,T2>::showperson() { cout << this->age << this->name <<ebdl; }
标签:类外,age,T2,c++,T1,person,template,模板,name 来源: https://www.cnblogs.com/uestc-du/p/16222082.html