Problem with ostringstream and copy constructor [duplicate]

你。 提交于 2019-12-02 04:20:32

Copy constructor and copy-assignment of any stream class in C++ has been made private. That means, you cannot make copy of std::ostringstream object:

std::ostringstream ss;

std::ostringstream ss1(ss); //not allowed - copy-constructor is private
ss1=ss; //not allowed - copy-assignment is private
iammilind

std::ostringstream is not copyable that's why you are getting error. See this answer for more details to know how you can overcome this problem.

T(const T& t)  {log << t.log.rdbuf(); }

I think ostringstream has no overloaded assignment(=) operator.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!