Reputation: 3487
I am trying to specialize this template method 'he' but couldn't compile. How to do it right?
#pragma once
template<typename A, typename B>
class template_test
{
public:
template_test();
~template_test();
template<typename C>
void he(C gg);
};
template<typename A, typename B>
template<typename C>
void template_test<A, B>::he( C gg )
{
}
template<typename A, typename B>
template<>
void template_test<A, B>::he( int gg )
{
}
error C1506: unrecoverable block scoping error
unable to match function definition to an existing declaration
Upvotes: 0
Views: 80
Reputation: 52405
You have specialize the class also. You cannot just specialize only the member:
template<>
template<>
void template_test<int, int>::he<int>( int gg )
{
}
However, instead, I would just add an overload:
void he(int gg){}
Upvotes: 3