error: variable 'std::ifstream ifs' has initializer but incomplete type

main.cpp: In function 'bool ReadTimeInterval(std::string&)':
main.cpp:134: error: variable 'std::ifstream ifs' has initializer but incomplete type
main.cpp:139: warning: deprecated conversion from string constant to 'char*'
main.cpp:139: warning: cannot pass objects of non-POD type 'const struct std::string' through '...'; call will abort at runtime

出现这个错误,是由于没有添加头文件:

添加 #include <fstream>

总结:这里看到了gcc的提示,incomlete type不完全的类型。

一般这种题目是因为缺乏头文件引起的,经常会碰到如许子的提示,所以记住产生incomplete type的原因。

原文地址:https://www.cnblogs.com/love-avrlinux/p/3555511.html