我創建這個模板,並把它在我的.cpp上面的main()的最頂端,但我仍然得到以下模板功能結果沒有發現
error: C3861: 'ConvertNumbertoString': identifier not found.
這裏是模板:
template<class T>
string ConvertNumberstoString(T number)
{
string outPut;
stringstream convert;
convert << number;
outPut = convert.str();
return outPut;
}
我知道這對大多數人來說可能是一個愚蠢的功能,但這正是我目前需要的。
我不知道如何擺脫這個錯誤,以便我可以在我的程序中使用它。
有什麼想法?
'的ToString()'將是功能的更好的名字。 – Nawaz
您需要展示如何使用該功能;這就是錯誤產生的地方。 –