Issue with stringstream

Hello,

I need some help with stringstream. I get an error when compiling a code. Here is a simple code that I am trying to run for now to debug the issue:

#include
#include
#include

stringstream variable;
variable << 123 << “Text” ;

cout << variable.str() ;

When I run the above code, I get an error message "operator not defined for basic_ostream<char, char_traits> (tmpfile)(1) interpretor error recovered*

Thanking you for any suggestions.

Let’s say the problem is that you allocated a generic stringstream (which is neither input nor output).
The correct code snippet should be:

[code]#include
#include
#include

ostringstream variable;
variable << 123 << “Text” ;

cout << variable.str() ;[/code]

In practice, ostringstream objects manage outputs (i.e. you can write data inside it), while istringstream objects manage inputs (i.e. you can read data from it).
Now, you should get no errors while running this snippet.

I hope this can help,

Andrea Demetrio