回复 10楼 Jonny0201
不把os绑定到输出流上,只把array中的数组输入到os中,然后在另外写个函数os中读取数据。还有一个小问题,
Foo(ostream &os) : os {os} {}
中的os{os}和os(os)的区别是什么呢?


程序代码:#include <iostream>
#include <sstream>
using namespace std;
int main( void )
{
istringstream is( "123" );
string s;
is >> s;
cout << s << endl;
}输出 123
程序代码:#include <iostream>
#include <sstream>
using namespace std;
int main( void )
{
ostringstream os;
os << "123";
cout << os.str() << endl;
}