template <class T>
class demo
{
T x,y;
public:
demo(T a, T b) : x(a),y(b){}
T module1(){return 0;}
};
template <>
class demo<int>
{
int x, y;
public:
demo(int a, int b) : x(a),y(b){}
int module1();
};
template <>
int demo<int>::module1()
{
return (x%y);
}
int main()
{
demo<int> O1(200, 30);
cout<<O1.module1()<<endl;
demo<float> O2(200.50, 30.50);
cout<<O2.module1()<<endl;
return 0;
}
while compiling M getting the error:
error C2910: 'demo<int>::module' : cannot be explicitly specialized.
why?
class demo
{
T x,y;
public:
demo(T a, T b) : x(a),y(b){}
T module1(){return 0;}
};
template <>
class demo<int>
{
int x, y;
public:
demo(int a, int b) : x(a),y(b){}
int module1();
};
template <>
int demo<int>::module1()
{
return (x%y);
}
int main()
{
demo<int> O1(200, 30);
cout<<O1.module1()<<endl;
demo<float> O2(200.50, 30.50);
cout<<O2.module1()<<endl;
return 0;
}
while compiling M getting the error:
error C2910: 'demo<int>::module' : cannot be explicitly specialized.
why?