C++ Fstream Library - Operator= Function
Description
It supported feature version of C++ 11 standard. It acquires the contents of right hand side, by move-assigning its members and base classes.
Declaration
Following is the declaration for fstream::operator=
C++11
copy (1) fstream& operator= (const fstream&) = delete; move (2) fstream& operator= (fstream&& rhs);
Parameters
rhs − Another fstream object.
Return Value
It returns *this.
Exceptions
No-throw guarantee − this member function never throws exceptions.
Data races
It modifies both stream objects (*this and rhs).
Example
In below example explains about fstream operator= function.
#include <fstream>
int main () {
std::fstream foo;
std::fstream bar ("test.txt");
swap(foo,bar);
foo << "tutorialspoint";
foo.close();
return 0;
}
fstream.htm
Advertisements