📅  最后修改于: 2020-12-15 04:19:17             🧑  作者: Mango
此数据类型通常表示文件流,并且具有ofstream和ifstream的功能,这意味着它可以创建文件,向文件写入信息以及从文件读取信息。
以下是std :: fstream的定义。
template<
class CharT,
class Traits = std::char_traits>
class basic_fstream : public std::basic_iostream
charT-别名为char_type成员。
特点-别名作为成员traits_type。
成员函数可以将以下成员类型用作参数或返回类型。
Sr.No. | Member types | Definition |
---|---|---|
1 | char | Character Type |
2 | char_traits |
traits_type |
3 | int | const value_type |
4 | int | int_type |
5 | streampos | pos_type |
6 | streamoff | off_type |
以下是
Sr.No. | Method & description |
---|---|
1 | fstream::close
Closes the file currently associated with the object, disassociating it from the stream. |
2 | fstream::is_open
Returns whether the stream is currently associated to a file. |
3 | fstream::open
Opens the file identified by argument filename, associating it with the stream object. |
4 | fstream::operator=
Returns a constant iterator which points to the start of the array. |
5 | fstream::rdbuf
Returns a pointer to the internal filebuf object. |
6 | fstream::swap
Exchanges all internal data between x and *this. |
Sr.No. | Method & description |
---|---|
1 | swap-free
Exchanges the values of the fstream objects x and y. |