#include <iostream>
#include <string>
#include <sstream>
using namespace std;
main()
{
ostringstream outputString;
string s1( "Output of several data types " ),
s2( "to an ostringstream object:" ),
s3( "\n double: " ),
s4( "\n int: " ),
s5( "\naddress of int: " );
double d = 123.4567;
int i = 22;
outputString << s1 << s2 << s3 << d << s4 << i << s5 << &i;
cout << "outputString contains:\n" << outputString.str();
outputString << "\nmore characters added";
cout << "\n\nafter additional stream insertions,\n"
<< "outputString contains:\n" << outputString.str()
<< endl;
return 0;
}