标签:c++
#include <iostream> #include <stdlib.h> using namespace std; template<class T> class xiaok{ public: static void han(){cout<<"xiao"<<endl;} static void han1(); static int i; // static const int ii=0; //vc.6报错 }; int xiaok<int>::i=1; int xiaok<char>::i=2; template<class T> int xiaok<T>::i=0; void xiaok<int>::han1(){cout<<"int"<<endl;} void xiaok<char>::han1(){cout<<"char"<<endl;} template<class T> void xiaok<T>::han1(){cout<<"T"<<endl;} int main(int argc, char const *argv[]) { xiaok<int> wi; xiaok<char> wc; xiaok<long> wl; cout<<xiaok<int>.i<<endl; cout<<wc.i<<endl; cout<<xiaok<long>.i<<endl; wi.han1(); xiaok<char>::han1(); wl.han1(); wl.han(); return 0; }
标签:c++
原文地址:http://blog.csdn.net/h1023417614/article/details/46398303