ofstream错误:error: variable ‘std::ofstream ofs’ has initializer but incomplete type

简介: ofstream错误:error: variable ‘std::ofstream ofs’ has initializer but incomplete type

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

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


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


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

 
#include<fstream> 
目录
相关文章
C++ 编译错误 error: ‘cout‘ was not declared in this scope (摄氏度与华氏度的转换)
C++ 编译错误 error: ‘cout‘ was not declared in this scope (摄氏度与华氏度的转换)
C++ 编译错误 error: ‘cout‘ was not declared in this scope (摄氏度与华氏度的转换)
|
安全 C语言
警告 1 warning C4996: ‘scanf‘: This function or variable may be unsafe.
警告 1 warning C4996: ‘scanf‘: This function or variable may be unsafe.
|
关系型数据库 MySQL C++
类型收窄 error C2397: conversion from ‘const int‘ to ‘char‘ requires a narrowing conversion
类型收窄 error C2397: conversion from ‘const int‘ to ‘char‘ requires a narrowing conversion
220 0
|
关系型数据库 MySQL C++
Error:E0415 no suitable constructor exists to convert from “int“ to “Rational“
Error:E0415 no suitable constructor exists to convert from “int“ to “Rational“
197 0
|
安全
VS2019 error C4996: ‘scanf‘: This function or variable may be unsafe 错误
VS2019 error C4996: ‘scanf‘: This function or variable may be unsafe 错误
374 0
VS2019 error C4996: ‘scanf‘: This function or variable may be unsafe 错误
TypeError: randint() received an invalid combination of arguments - got (int, int, int), but expecte
TypeError: randint() received an invalid combination of arguments - got (int, int, int), but expecte
725 0
|
C++
warning C4996 sprintf This function or variable may be unsafe
warning C4996 sprintf This function or variable may be unsafe
95 0
|
Python
【hacker的错误集】TypeError: can‘t multiply sequence by non-int of type ‘str‘
我比较喜欢通过单词的意思来分析报错 TypeError类型错误 multiply乘 sequence 序列 通过分析可以得出报错意思大概是类型错误:无法将序列与字符串类型的非整数相乘
391 0
【hacker的错误集】TypeError: can‘t multiply sequence by non-int of type ‘str‘
|
C++
warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
208 0
|
编译器 Linux C语言
报错storage size of ‘sa’ isn’t known,当使用std=c99编译struct sigaction
报错storage size of ‘sa’ isn’t known,当使用std=c99编译struct sigaction
860 0
报错storage size of ‘sa’ isn’t known,当使用std=c99编译struct sigaction