Given:
template<class T>
struct test {
void foo(int b);
void testFunc( int a )
{
}
};
void test::foo(int b)
{
}
template<>
void test<float>::testFunc( int a )
{
}
void someFunction()
{
}
We know that “test::foo” has a declaration in the test class, and a definition outside the class definition.
We also know that “someFunction” has a declaration which is also its definition.
In like manner “test::testFunc” (non-specialized), has a declaration which is also its definition.
Is the specialization function “test<float>::testFunc” said to be declared with the declaration of “testFunc” inside of class “test” and defined separately, or is its declaration also the definition?
The explicit specialization in your example is a declaration that is also a definition. You could also declare it separately:
and if the function was used, the linker would expect it to be defined somewhere.
The declaration inside the class is the declaration and definition of the member function template.
BTW, foo should be defined like this: