#include<iostream.h>
template<class T>
class Sample
{
T n;
public:
Sample(T i){n=i;}
int operator==(Sample&);
};
template<class T>
int Sample<T>::operator==(Sample&s)
{
if(n==s.n)
return 1;
else
return 0;
}
void main()
{
Sample<int>s1(2),s2(3);
cout<<"s1与s2的数据成员"<<(s1==s2?"相等":"不相等")<<endl;
Sample<double>s3(2.5),s4(2.5);
cout<<"s3与s4的数据成员"<<(s3==s4?"相等":"不相等")<<endl;
}
S1与S2的数据成员不相等
S3与S4的数据成员相等