我在C++中得到了一个ofstream错误,这是我的代码
int main () {
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}来自Dev-C++ 10的错误
C:\devp\main.cpp聚合‘`std::ofstream OutStream’具有不完整的类型,无法定义
提前感谢
发布于 2009-06-29 09:26:17
你可以试试这个:
#include <fstream>
int main () {
std::ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}发布于 2009-06-29 09:28:38
文件流实际上是在<fstream>中定义的。
发布于 2018-02-10 21:51:02
您可能不包括审批头文件。
在源文件请求时添加#include <fstream>应该会修复这个错误。
https://stackoverflow.com/questions/1057287
复制相似问题