此數據類型通常用來表示檔流,並且具有 stream 和 ifstream 的能力,也就是說它可以創建檔,向檔寫入資訊和從檔讀取資訊。
定義
下麵是 std::fstream 的定義。
template<
class CharT,
class Traits = std::char_traits<CharT>>
class basic_fstream : public std::basic_iostream<CharT, Traits>
參數
charT− 作為成員char_type的別名。traits- 作為成員traits_type的別名。
成員類型
以下成員類型可以用作參數或由成員函數返回類型。
| 成員類型 | 定義 |
|---|---|
| char | 字元類型 |
| char_traits |
traits_type |
| int | const value_type |
| int | int_type |
| streampos | pos_type |
| streamoff | off_type |
的函數
下麵是<fstream>中所有方法的列表,成員函數 -
| 編號 | 描述和說明 |
|---|---|
| 1 | fstream::close - 關閉當前與對象關聯的檔,將其與流分離。 |
| 2 | fstream::is_open - 返回當前流是否與檔相關聯。 |
| 3 | fstream::open - 打開由參數filename標識的檔,將其與流對象相關聯。 |
| 4 | fstream::operator= - 返回一個常量迭代器,它指向數組的開始。 |
| 5 | fstream::rdbuf - 返回指向內部filebuf對象的指針。 |
| 6 | fstream::swap - 在 x 和 *this 之間交換所有內部數據。 |
非成員重載函數
| 編號 | 描述和說明 |
|---|---|
| 1 | swap-free - 交換fstream對象x和y的值。 |
上一篇:
下一篇:
fstream::close()函數
