0
template<int* A,int* B>
void f()
{
}
template<int A,int B>
void f()
{
}
void main()
{
f<(int*)1,(int*)2>();
}
我想要我的模板finjing f
兩個specializtions。但是這個代碼沒有編譯。有什麼問題?模板函數的兩個特化(int和int *)。編譯錯誤
Error 1 error C2440: "specialization" : cannot convert from "int *" to "const int" line 11
Error 2 error C2973: invalid template argument "int *" line 11
Error 3 error C2440: "specialization" : cannot convert from "int *" to "const int" line 11
Error 4 error C2973: invalid template argument "int *" line 11
Error 5 error C2668: 'f' : ambiguous call to overloaded function line 11
編譯器的Visual C++ 2010
好的,你會得到錯誤,但_what_錯誤?請修改您的問題以顯示實際錯誤。 – 2012-01-13 07:07:59