在使用std::ofstream写文件时,编译器提示如下错误:

error: variable ‘std::ofstream ofs’ has initializer but incomplete type
std::ofstream ofs(string(TMP_STATE_FILE));

这个错误上由于没有保护头文件导致的。

包含上头文件,编译通过。

#include<fstream>