摘要: #include<iostream>#include<string>using namespace std;template<class T>class TBase{ T data1; public: void print() { cout<<"TBase::"<<data1<<endl; }};t 阅读全文
posted @ 2020-04-20 09:58 CollisionDimension 阅读(86) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>using namespace std; template<class T>class TBase{private: T data1;public: void print() { cout<<"TBase::"<<data1<<en 阅读全文
posted @ 2020-04-20 09:56 CollisionDimension 阅读(115) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>using namespace std;class TBase{ int k;public: void print() { cout<<"TBase::"<<k<<endl; }}; template<class T>class T 阅读全文
posted @ 2020-04-20 09:50 CollisionDimension 阅读(180) 评论(0) 推荐(0) 编辑
摘要: /* 类模板与继承: ~P345类之间允许继承,类模板之间也允许继承。1)普通类继承模板类。2)类模板继承普通类。3)类模板继承类模板。4)类模板继承模板类。 */ #include<iostream>using namespace std;template<class T>class TBase{ 阅读全文
posted @ 2020-04-20 09:45 CollisionDimension 阅读(373) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;template<int i>class TestClass{ public: int buffer[i]; int getData(int j);};template<int i>int TestClass<i>::get 阅读全文
posted @ 2020-04-20 09:42 CollisionDimension 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 程序添加少数与课本内容不同,若许采用请注意! 原因:少许程序无法正常运行! 阅读全文
posted @ 2020-04-20 09:34 CollisionDimension 阅读(157) 评论(0) 推荐(0) 编辑