1 template<class T> 2 class Set { 3 public: 4 typedef int (*Compare)(const T&, const T&); 5 static Compare cmp1; 6 static int (*cmp2)(const T&, const T&); 7 }; 8 9 template<class T> gen_cmp(const T & a,const T & b)10int gen_cmp(const T& a, const T& b) { 11 if (a<b) return -1; 12 else if (a==b) return 0; 13 else return 1; 14 } 15 16 template<class T> 17 typename Set<T>::Compare Set<T>::cmp1 = &gen_cmp; 18 19 template<class T> 20 int (*Set<T>::cmp2)(const T&, const T&) = &gen_cmp; 21 main()22int main() { 23 Set<int> s; 24 } 25