error: invalid use of incomplete type ‘struct foo::bar’

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.

example:

// main.cpp
        std::stringstream(mystring) >> yours.year;

compile:

g++ main.cpp -o run
main.cpp: In function ‘int main()’:
main.cpp:41: error: invalid use of incomplete type ‘struct std::stringstream’
/usr/include/c++/4.4/iosfwd:75: error: declaration of ‘struct std::stringstream’
make: *** [run] Error 1

Reason: the header for stringstream was missing. Add the following:

<pre>

#include &lt;sstream>

</pre>