C2065:'oss'未声明的标识符
C2065: 'oss' undeclared identifier
我使用Qt Creator,我在我的c++代码中有一个奇怪的错误。这段代码
#include <stdlib.h>
std::wstring readFile(const std::wstring& f) {
//try and open the file
std::wifstream file(TL::wToString(f).c_str());
if (!file)
throw BadFileLoad(f, L"Impossible to write in the file "+f);
//reads the content
std::wostringstream oss;
oss << file.rdbuf();
return oss.str();
}
给出这个错误:
C2065: 'oss'未声明的标识符
但实际上我在第一行就声明了!!怎么了?谢谢!
您需要包含具有std::wostringstream
类的标题
#include <sstream>
您缺少一些包含文件。试试这样做:
#include <string> // std::wstring
#include <sstream> // std::wostringstream
#include <fstream> // std::wifstream
我发现了错误,我注释了这行抛出BadFileLoad(f, L"Impossible to write in the file "+f);而不是if (!file)…对不起,伙计们,这是个愚蠢的问题!感谢您的宝贵时间!
相关文章:
- #ifdef和未声明的标识符
- 未声明的标识符编译暗黑破坏神 2 程序"muleview"
- 在顶点着色器中使用 OpenGl 的未声明标识符,我在顶点着色器中绘制三角形时遇到问题
- Google protobuf 时间戳未声明标识符,在 Windows 上具有C++
- 使用未声明的标识符"sqrt"?
- 对类 (C++) 中的私有变量使用未声明的标识符
- 我的代码中有错误,未声明的标识符
- 未定义的标识符/未声明
- 错误:在 C++ 'std'使用未声明的标识符
- 在编译器之前检测未声明的标识符
- 使用未声明的标识符'temp'
- 使用未声明的标识符"yylex"和"yyin"?
- 使用"class"关键字,后跟未声明的标识符
- 未声明的标识符错误,但变量定义正确 (?)
- C2065 'cout':未声明的标识符
- C++模板模板参数中未声明的标识符
- 错误:在 C++ 目标 c 混合'self'使用未声明的标识符
- C++循环依赖关系,未声明的标识符
- 我的函数调用 (C++) 中的未声明标识符
- 未找到标识符和未声明的标识符