1 #include <iostream>
2 #include <cstdlib>
3 using namespace std;
4
5 //类模板支撑封装 继承 还有多态
6 template<class T>
7 class Tfu
8 {
9 public:
10 T t;
11 Tfu():t(0)
12 {
13
14 }
15 void show()
16 {
17 cout << t << endl;
18 }
19
20 virtual void go()
21 {
22 cout << "go" << endl;
23 }
24 };
25
26 template<class T>
27 class Tzi :public Tfu<T>
28 {
29 public:
30 void go()
31 {
32 cout << "gogogo" << endl;
33 }
34
35 };
36
37 //普通类继承模板类
38 class zi :public Tfu<int>
39 {
40 public:
41 void go()
42 {
43 cout << "gogogogo" << endl;
44 }
45 };
46
47 void main()
48 {
49 /*Tzi<int> tzi;
50 tzi.t = 100;
51 tzi.show();*/
52 /*Tfu<int> *p = new Tzi<int>;
53 p->go();*/
54
55 Tfu<int> *p = new zi;
56 p->go();
57 cin.get();
58 }