我以前遇到过这个问题,但找到了解决办法,只是这次解决办法不是一种选择.
我正在尝试使用'stof'函数,但我收到的错误是:'stof'不是'std'的成员'函数'stof'无法解析
如果在此页面上显示,我正在使用它:http://www.cplusplus.com/reference/string/stof/
这是我的包括:
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
Run Code Online (Sandbox Code Playgroud)
那么,我做错了什么?如果一个解决方案不能被发现可能有人点我的另一种方式将字符串转换为浮动,并把它抛出一个异常,如果字符串是不兼容?
编辑:使用示例程序和错误进行更新.
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
string testString = "";
float testFloat = 0.0;
testFloat = std::stof(testString);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
说明资源路径位置类型'stof'不是'std'main.cpp/Assignment/src第33行的成员C/C++问题
说明资源路径位置类型函数'stof'无法解析main.cpp/Assignment/src第33行语义错误
| 归档时间: |
|
| 查看次数: |
17422 次 |
| 最近记录: |