CHAPTER3-15.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:0k
源码类别:

STL

开发平台:

C/C++

  1. //文件名:CHAPTER3-15.cpp
  2. #include <iostream.h>
  3. class X 
  4. {public: 
  5. void f() {   cout<<"This is fuction f()"<<endl;} 
  6. }; 
  7. class Y 
  8. {public: 
  9. void g() {   cout<<"This is fuction g()"<<endl; } 
  10. }; 
  11. template <typename T> class Z 
  12. {T t; 
  13. public: 
  14. void a() { t.f(); } 
  15. void b() { t.g(); } 
  16. }; 
  17. int main() 
  18. {Z<X> zx; 
  19. zx.a(); // Doesn't create Z<X>::b() 
  20. Z<Y> zy; 
  21. zy.b(); // Doesn't create Z<Y>::a()
  22. } ///:~