它支持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;
}
上一篇:
fstream::open()函數
下一篇:
fstream::rdbuf()函數