我一直在嘗試理解模板專業化。這是爲什麼產生錯誤(specialization of 'T foo(T, T) [with T = int]' after instantiation
)C++中的模板專業化
template <class T> T foo(T a, T b);
int main()
{
int x=34, y=54;
cout<<foo(x, y);
}
template <class T> T foo(T a, T b)
{
return a+b;
}
template <> int foo<int>(int a, int b)
{
cout<<"int specialization";
}
之前'main'只是移動的定義。 –
坐在t雨閱讀thw問題與我的android手機,但不能夠及時回答HURTS –
@ JohannesSchaub-litb你上癮!尋求幫助 ;) –