请教:解释一下这段模板特化的问题
#include <stdio.h>
template<typename T>
struct box
{
template<typename TK>
struct test
{
void ShowType(void)
{
printf( "\n俺是未定义" );
}
};
template<>
struct test<int>
{
void ShowType(void);
};
};
template<typename T>
template<TK>
void box<T>::test<int>::ShowType(void)
{
printf("\n俺是int");
}
void main(void)
{
box<int>::test<int> s;
s.ShowType();
getchar();
}
//上面这一小段代码可以正常的编译,但无法通过链接。为什么呢?
//如果把对int的特化的定义放在box的定义里一起定义的话,就一切正常了。
//感觉是特化的地方写的不对,请帮助改正。谢谢。