【发布时间】:2011-08-13 10:00:28
【问题描述】:
可能的重复:
Why copying stringstream is not allowed?
how copy from one stringstream object to another in C++?
编译类 T 失败,Visual C++ 和 GCC 产生 iostreams 模板错误。代码如下:
#include <sstream>
class T
{
static T copy;
std::ostringstream log;
T() {}
T(const T& t) {log = t.log;}
~T() {copy = *this;}
};
T T::copy;
将 log 数据成员类型更改为字符串使其编译和运行正常。这是合法的行为吗?
【问题讨论】:
标签: c++ copy-constructor ostringstream