Incomplete type is not allowed: stringstream

时间秒杀一切 提交于 2019-11-27 20:06:35

问题


Why does this line give the error Error: incomplete type is not allowed?

stringstream ss;

回答1:


#include <sstream> and use the fully qualified name i.e. std::stringstream ss;




回答2:


Please, add:

#include <sstream>



回答3:


An incomplete type error is when the compiler knows the identifier is a type, for instance because you have a forward-declaration of it (e.g. class stringstream;), but it hasn't seen a full definition for it (class stringstream { ... };).

This could happen for a type that is only present through included header files -- when you've included header files that use the type, but not the header file where the type is defined. It's unusual for a header to not itself include all the headers it needs, but not impossible.

For things from the standard library, such as the stringstream class, use the reference documentation (e.g. Unix man pages, MSDN library, etc.) to figure out what you need to #include to use it and what namespace to find it in if any. You may need to search for pages where the class name appears (e.g. man -k stringstream).



来源:https://stackoverflow.com/questions/5781597/incomplete-type-is-not-allowed-stringstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!