1: #ifndef _FOO_H_
2: #define _FOO_H_
3: #include <stdio.h>
4: #include<iostream>
5: #include<string>
6:
7: class foo
8: {
9: public:
10: template<typename T>
11: void Saytype(const T&)
12: {
13: std::cout <<"unrecognized type !"<<std::endl;
14: }
15:
16: // 下面的全特化在 vc6下编译通过,但g++ 4.1.2 编译失败
17: // template<>
18: // void Saytype<int>(const int & )
19: // {
20: // std::cout<<" type is int";
21: // }
22: // g++上可以使用重载来代替全特化
23: void Saytype(const int &)
24: {
25: std::cout<<" type is int";
26: }
27: };
28:
29: #endif