我有归结为以下代码:C++模板专业化问题
//Just a templated array class .. implementation doesn't matter
template<int N>
struct Array {};
//A simple Traits like class
template<typename T>
struct MyTraits {}
//Specialization of the traits class
template<int N>
struct Foo< Array<N> >
{
static void monkey() {};
}
int main()
{
Foo< Array<3> >::monkey();
}
不幸的是,编译器不喜欢它... ...
test.cpp: In function ‘int main()’:
test.cpp|17| error: ‘monkey’ is not a member of ‘Foo<Array<3> >’
我在做什么错了,怎么办我修复它? 感谢
我错过了什么,或者你不使用你的特质课程? 'Foo'应该是'MyTraits'吗? – GManNickG 2010-01-06 07:28:53