Espacios de nombres
Variantes

std::basic_ofstream::basic_ofstream

De cppreference.com

[edit template]
 
 
Biblioteca de E/S
Manipuladores de E/S
E/S estilo C
Búferes
(en desuso en C++98)
Flujos
Abstracciones
E/S de archivos
E/S de cadenas
E/S de arrays
(en desuso en C++98)
(en desuso en C++98)
(en desuso en C++98)
Salida sincronizada
Tipos
Interfaz de categoría de error
(C++11)
 
std::basic_ofstream
Las funciones miembro
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Las operaciones de archivo
Original:
File operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Terceros funciones
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
<tbody> </tbody>
basic_ofstream();
(1)
basic_ofstream( const char* filename, {{#pad:|14}} ios_base::openmode mode = ios_base::out );
(2)
basic_ofstream( const string& filename, {{#pad:|14}} ios_base::openmode mode = ios_base::out );
(3) (desde C++11)
basic_ofstream( basic_ofstream&& other );
(4) (desde C++11)
basic_ofstream( const basic_ofstream& rhs) = delete;
(5)
Construye secuencia de archivo nuevo .
Original:
Constructs new file stream.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
Constructor por defecto: construye una corriente que no está asociado con un archivo: default-construye el std::basic_filebuf y construye la base con el puntero para esta default-construido miembro std::basic_filebuf .
Original:
Default constructor: constructs a stream that is not associated with a file: default-constructs the std::basic_filebuf and constructs the base with the pointer to this default-constructed std::basic_filebuf member.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
En primer lugar, realiza los mismos pasos que el constructor por defecto, entonces asssociate la corriente con un archivo llamando rdbuf()->open(filename, mode | std::ios_base::out).. Si la llamada open () devuelve un puntero nulo, se establece setstate(failbit) .
Original:
First, performs the same steps as the default constructor, then asssociate the stream with a file by calling rdbuf()->open(filename, mode | std::ios_base::out).. If the open() call returns a null pointer, sets setstate(failbit).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Igual que basic_ofstream(filename.c_str(), mode) .
Original:
Same as basic_ofstream(filename.c_str(), mode).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Mueva constructor. En primer lugar, se mueven-construye la clase base de other (que no afecta el puntero rdbuf()), a continuación, mover-construye el miembro std::basic_filebuf, a continuación, llama this->set_rdbuf() para instalar el nuevo basic_filebuf como el puntero rdbuf() en la clase base .
Original:
Move constructor. First, move-constructs the base class from other (which does not affect the rdbuf() pointer), then move-constructs the std::basic_filebuf member, then calls this->set_rdbuf() to install the new basic_filebuf as the rdbuf() pointer in the base class.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
El constructor de copia se borra: esta clase no es copiable .
Original:
The copy-constructor is deleted: this class is not copyable.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parámetros

filename -
el nombre del archivo que se abrirá
Original:
the name of the file to be opened
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mode -
especifica el modo de transmisión abierta. Es el tipo de máscara de bits, las siguientes constantes son definidas:
Constante Explicación
app Busca hasta al final del flujo antes de cada escritura.
binary Abrir en modo binario.
in Abrir para lectura.
out Abrir para escritura.
trunc Descartar el contenido del flujo al abrir.
ate Busca hasta al final del flujo inmediatamente después de abrirlo.
noreplace (C++23) Abrir en modo exclusivo.
Original:
specifies stream open mode. It is bitmask type, the following constants are defined:
Constante Explicación
app Busca hasta al final del flujo antes de cada escritura.
binary Abrir en modo binario.
in Abrir para lectura.
out Abrir para escritura.
trunc Descartar el contenido del flujo al abrir.
ate Busca hasta al final del flujo inmediatamente después de abrirlo.
noreplace (C++23) Abrir en modo exclusivo.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
other -
otra fuente de archivo que se utilizará como fuente
Original:
another file stream to use as source
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Ejemplo

#include <fstream>
#include <utility>
#include <string>
int main()
{
std::basic_ofstream f0;
    std::ofstream f1("test.bin", std::ios::binary);
    std::string name = "example.txt";
    std::ofstream f2(name);
    std::ofstream f3(std::move(f1));
}


Ver también

abre un archivo y lo asocia con la corriente
Original:
opens a file and associates it with the stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(función miembro pública) [editar]
Abre un archivo y lo configura como la secuencia de caracteres asociada.
(función miembro pública de std::basic_filebuf) [editar]
sustituye a la rdbuf sin borrar su estado de error
Original:
replaces the rdbuf without clearing its error state
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(función miembro protegida) [editar]
Construye el objeto
Original:
constructs the object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(función miembro pública de std::basic_ostream<CharT,Traits>) [editar]