std::basic_ofstream::basic_ofstream
De cppreference.com
|
|
Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate.
La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
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.
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.
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.
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.
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.
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.
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:
Original: specifies stream open mode. It is bitmask type, the following constants are defined:
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
Ejecuta este código
#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) | |
| Abre un archivo y lo configura como la secuencia de caracteres asociada. (función miembro pública de std::basic_filebuf)
| |
sustituye a la rdbuf sin borrar su estado de errorOriginal: replaces the rdbuf without clearing its error stateThe 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) | |
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>)
|