为什么这个程序编译出错,请高手解释一下,谢谢
#include<iostream.h>
#include<stdlib.h>
struct gou //创建结构体
{
int cf;
int ch;
};
template <class t> //创建一个类模板
class lei
{
private:
t x;
t y;
public:
lei(void);
void f(t xx);
t w(void);
};
template <class t>
lei<t>::lei(void):y(0){}
template <class t>
t lei<t>::w(void)
{
if(y==0)
{cout<<"no"<<endl;
exit(1);
}
return x;
}
template <class t>
void lei<t>::f(t xx)
{y++;
x=xx;
}
void main()
{ gou g={1000,20};
lei <int>s1,s2;
lei <gou> c2;
lei<double>c1;
s1.f(3);
s2.f(-7);
cout<<s1.w()<<"\n"<<s2.w();
c2.f(g);
cout<<c2.w().cf<<endl;
cout<<c1.w()<<endl;
}