- //文件名:CHAPTER3-15.cpp
- #include <iostream.h>
- class X
- {public:
- void f() { cout<<"This is fuction f()"<<endl;}
- };
- class Y
- {public:
- void g() { cout<<"This is fuction g()"<<endl; }
- };
- template <typename T> class Z
- {T t;
- public:
- void a() { t.f(); }
- void b() { t.g(); }
- };
- int main()
- {Z<X> zx;
- zx.a(); // Doesn't create Z<X>::b()
- Z<Y> zy;
- zy.b(); // Doesn't create Z<Y>::a()
- } ///:~