1 // Test for obsolete specialization syntax. Turn off -pedantic. 2 // Special g++ Options: 3 4 #include <iostream> 5 #include <typeinfo> 6 7 template <typename T> 8 class A { 9 public: 10 void test (); 11 }; 12 13 template <typename T> 14 void test()15A<T>::test(){ 16 std::cerr << "test for " << typeid(*this).name() << std::endl; 17 } 18 // Specialization declaration 19 void 20 A<double>::test(); 21 22 // Specialization definition 23 void test()24A<double>::test(){ 25 std::cerr << "specialization for " << typeid(*this).name() << std::endl; 26 } 27 28 29 int main()30main(){ 31 A<int> ai; 32 A<double> ad; 33 ai.test(); 34 ad.test(); 35 return 0; 36 } 37 38 39