模板函数导致找不到标识符
我已经创建了这个模板,并将其放在 main() 上方的 .cpp 的最顶部,但我仍然得到以下内容
错误:C3861:“ConvertNumbertoString”:找不到标识符。
这是模板:
template<class T>
string ConvertNumberstoString(T number)
{
string outPut;
stringstream convert;
convert << number;
outPut = convert.str();
return outPut;
}
我知道这对你们大多数人来说可能是一个愚蠢的功能,但这是我目前所需要的。
我不知道如何消除这个错误,以便我可以在我的程序中使用它。
有什么想法吗?
I've created this template, and put it at the very top of my .cpp above main() but I am still getting the following
error: C3861: 'ConvertNumbertoString': identifier not found.
Here is the template:
template<class T>
string ConvertNumberstoString(T number)
{
string outPut;
stringstream convert;
convert << number;
outPut = convert.str();
return outPut;
}
I know this is probably a stupid function to most of you guys, but it's what I need at the moment.
I can't figure out how to get rid of this error so that I can use it in my program.
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想从函数模板返回一个字符串:
You want to return a string from the function template: