C++ 文件流库 - 赋值运算符函数



描述

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

声明

以下是 fstream::operator= 的声明

C++11

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

参数

rhs - 另一个 fstream 对象。

返回值

它返回 *this。

异常

无抛出保证 - 此成员函数从不抛出异常。

数据竞争

它修改两个流对象(*this 和 rhs)。

示例

以下示例说明了 fstream 赋值运算符函数。

#include <fstream>

int main () {
   std::fstream foo;
   std::fstream bar ("test.txt");

   swap(foo,bar);

   foo << "tutorialspoint";

   foo.close();

   return 0;
}
fstream.htm
广告

© . All rights reserved.