为什么这行代码会出现 Error: incomplete type is not allowed
的错误?
stringstream ss;
为什么这行代码会出现 Error: incomplete type is not allowed
的错误?
stringstream ss;
使用完全限定名称,即std::stringstream ss;
,并包含头文件#include <sstream>
一些系统头文件提供了std::stringstream
的前向声明但没有定义。这使它成为一个“不完整类型”。要修复此问题,您需要包含定义,该定义在<sstream>
头文件中提供:
#include <sstream>
不完整类型
错误发生于编译器遇到一个标识符的使用,该标识符是一个类型,例如因为它已经看到了它的前向声明(例如class stringstream;
),但没有看到它的完整定义(例如class stringstream { ... };
)。stringstream
类,请使用语言标准或其他参考文档来查找类或单个函数(例如Unix man
页面、MSDN库等)需要#include
以及是否需要找到它所在的名称空间。 您可能需要搜索出现类名的页面(例如man -k stringstream
)。
#include<stringstream>
或者其他什么东西? #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <string> #include <fstream> #include <cstdlib> #include <vector> - pighead10