variable 'std:ofstream’ has initializer but incomplete type
或者是variable 'std:ifstream’ has initializer but incomplete type
其原因是因为没有包含fstream这个头文件。
#include<fstream> #include<iostream> #include<string> using namespace std; int main() { fstream f("filename"); f << 20; f.close(); }上面这段代码如果没有那个<fstream>就会有标题的错误。
解决fstream初始化错误
本文介绍了一个常见的编程问题:使用fstream时出现的初始化错误,并提供了解决方案。通过确保正确包含了必要的头文件,可以避免此类错误的发生。
2万+

被折叠的 条评论
为什么被折叠?



