basic_ifstream 클래스
Describes an object that controls extraction of elements and encoded objects from a stream buffer of class basic_filebuf<Elem, Tr>, with elements of type Elem, whose character traits are determined by the class Tr.
template <class Elem, class Tr = char_traits<Elem> >
class basic_ifstream : public basic_istream<Elem, Tr>
매개 변수
Elem
The basic element of the file buffer.Tr
The traits of the basic element of the file buffer (usually char_traits<Elem>).
설명
The object stores an object of class basic_filebuf<Elem, Tr>.
예제
The following example shows how to read in text from a file.
// basic_ifstream_class.cpp
// compile with: /EHsc
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
ifstream ifs("basic_ifstream_class.txt");
if (!ifs.bad())
{
// Dump the contents of the file to cout.
cout << ifs.rdbuf();
ifs.close();
}
}
Input: basic_ifstream_class.txt
This is the contents of basic_ifstream_class.txt.
Output
This is the contents of basic_ifstream_class.txt.
생성자
basic_ifstream 개체의 새 인스턴스를 초기화합니다. |
멤버 함수
Closes a file. |
|
Determines if a file is open. |
|
파일을 엽니다. |
|
Returns the address of the stored stream buffer. |
|
Exchanges the content of this basic_ifstream for the content of the provided basic_ifstream. |
연산자
Assigns the content of this stream object. This is a move assignment involving an rvalue that does not leave a copy behind. |
요구 사항
Header: <fstream>
네임스페이스: std