4 我可以做的std :: ostringstream愁楚 std::ostringstream oss; oss << 1; oss.str(); 所以为什么我不能做: ((std::ostringstream()) << 1).str() ? 谢谢! 来源 2010-02-03 anon +0 错误说的是什么? – 2010-02-03 22:56:08 +0 你究竟想要完成什么? – 2010-02-03 22:58:00 +3 另请参见:http://stackoverflow.com/questions/1540831/stringstream-temporary-ostream-return-problem与使用临时stringstreams有趣的问题。 – 2010-02-03 23:01:22
11 的<<运算符返回基类型ostream,而只存在所导出的类型ostringstream的str成员函数。 来源 2010-02-03 22:58:58 interjay +1 (oss << 1).str()以同样的方式失败。 ostream不支持str() – pm100 2010-02-03 23:03:42 +0 你可以将它重新转换为ostringstream吗? – Inverse 2010-02-04 06:02:30 +0 是的,将它重新投放会有效。 – interjay 2010-02-04 14:47:59
错误说的是什么? – 2010-02-03 22:56:08
你究竟想要完成什么? – 2010-02-03 22:58:00
另请参见:http://stackoverflow.com/questions/1540831/stringstream-temporary-ostream-return-problem与使用临时stringstreams有趣的问题。 – 2010-02-03 23:01:22