我有歸結爲以下代碼: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