다음을 통해 공유


basic_ofstream 클래스

Describes an object that controls insertion of elements and encoded objects into 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_ofstream : public basic_ostream<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>).

설명

When the wchar_t specialization of basic_ofstream writes to the file, if the file is opened in text mode it will write a MBCS sequence. The internal representation will use a buffer of wchar_t characters.

The object stores an object of class basic_filebuf<Elem, Tr>.

예제

The following example shows how to create a basic_ofstream object and write text to it.

// basic_ofstream_class.cpp
// compile with: /EHsc
#include <fstream>

using namespace std;

int main(int argc, char **argv)
{
    ofstream ofs("ofstream.txt");
    if (!ofs.bad())
    {
        ofs << "Writing to a basic_ofstream object..." << endl;
        ofs.close();
    }
}

생성자

basic_ofstream

basic_ofstream 형식의 개체를 만듭니다.

멤버 함수

close

Closes a file.

is_open

Determines if a file is open.

open

파일을 엽니다.

rdbuf

Returns the address of the stored stream buffer.

스왑

Exchange the contents of this basic_ofstream for the contents of the provided basic_ofstream.

연산자

operator=

Assigns the content of this stream object. This is a move assignment involving an rvalue reference that does not leave a copy behind.

요구 사항

Header: <fstream>

네임스페이스: std

참고 항목

참조

basic_ostream 클래스

C++ 표준 라이브러리의 스레드 보안

iostream 프로그래밍

iostreams 규칙

기타 리소스

<fstream> 멤버

basic_ofstream 멤버