ostream运算符=

它支持C++ 11标准版本的功能。它通过移动分配其成员和基类来获取右侧的内容。

声明

以下是ostream::operator=的声明
C++11

copy (1)    fstream& operator= (const fstream&) = delete;
move (2)    fstream& operator= (fstream&& rhs);

参数

  • rhs − 另外的一个fstream对象。

返回值

  • 它返回 *this

示例

在下面的例子中解释了 ostream 运行符 = 函数。

#include <fstream>
int main () {
std::fstream foo;
std::fstream bar ("test.txt");
swap(foo,bar);
foo << "cpp fstream operator";
foo.close();
return 0;
}

以上是ostream运算符=的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>