gpt4 book ai didi

c++ - ostringstream 和复制构造函数的问题

转载 作者:行者123 更新时间:2023-11-30 00:40:06 25 4
gpt4 key购买 nike

<分区>

Possible Duplicates:
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 数据成员类型更改为字符串使其编译和运行正常。这是合法行为吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com