Is it possible to do this kind of specialization?
If so, how?
The specialization in question is marked //THIS SPECIALIZATION WILL NOT COMPILE I have used VS2008, VS2010, gcc 4.4.3 and neither can compile this.
I know i can avoid this by overloading func but i want to know if there is a way to do this with template specialization. (impractical/inadvisable though it may be)
#include<iostream>
#include<string>
using namespace std;
template <typename ALPHA>
class klass{
public:
template <typename BETA>
void func(BETA B);
};
template <typename ALPHA> template <typename BETA>
void klass<ALPHA>::func(BETA B){
cout << "I AM A BETA FUNC: " << B <<endl;
}
//THIS SPECIALIZATION WILL NOT COMPILE
template <typename ALPHA> template <>
void klass<ALPHA>::func(string B){
cout << "I AM A SPECIAL BETA FUNC: " << B <<endl;
}
int main(){
klass<string> k;
k.func(1);
k.func("hello");
return 0;
}