【1】问题描述
最近在写工具的时候,代码编译出现 variable 'std:ofstream’ has initializer but incomplete type 或者是 variable 'std:ifstream’ has initializer but incomplete type
【2】原因
因为没有包含fstream这个头文件。
【3】代码详解
#include<fstream>
#include<iostream>
#include<string>
using namespace std;
int main() {
fstream f("filename");
f << 20;
f.close();
}
上面的代码,如果不包含fstream头文件,就无法完成编译。
搞定!
allenlinrui
2014/02/21