代码:
#include<iostream>
using namespace std;
template<typename T>
class XYZ
{
public:
void putpri();
static T ipub;
private:
static T ipri;
};
template <typename T>
void XYZ<T>::putpri()
{
cout<<ipri++<<endl;
}
template <typename T>
T XYZ<T>::ipub =1;
template <typename T>
T XYZ<T>::ipri = 1.2;
int main(int argc, char** argv)
{
XYZ<int> aaa;
XYZ<float> bbb;
aaa.putpri();
cout<<aaa.ipub<<endl;
bbb.putpri();
}