I have a class template, let's call it A
, which has a member function abc()
:
template <typename T>
class A{
public:
T value;
void abc();
};
I can implement the member function abc()
outside the class declaration, using the following syntax:
template <typename T>
void A<T>::abc()
{
value++;
}
What I want to do is to create a template specialization for this class, let's say int
.
template <>
class A<int>{
public:
int value;
void abc();
};
The question is: what is the correct syntax to implement abc()
for the specialized class?
I tried using the following syntax:
template <>
void A<int>::abc()
{
value += 2;
}
However this doesn't compile.