std::basic_ofstream::basic_ofstream
De cppreference.com
<metanoindex/>
<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) | |
Constrói fluxo de arquivo novo.
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)
Construtor padrão: constrói um fluxo que não está associado a um arquivo: default-constrói a std::basic_filebuf e constrói a base com o ponteiro para esse membro padrão construído 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)
Primeiro, executa os mesmos passos que o construtor padrão, então asssociate o fluxo com um arquivo chamando
rdbuf()->open(filename, mode | std::ios_base::out).. Se a chamada open () retorna um ponteiro nulo, define 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)
Mesmo 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)
Mova construtor. Primeiro, mover-constrói a classe base de
other (que não afeta o ponteiro rdbuf()), em seguida, passar-constrói o membro std::basic_filebuf, em seguida, chama this->set_rdbuf() para instalar o novo basic_filebuf como o ponteiro rdbuf() na classe 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)
O construtor de cópia é apagado: esta classe não é copiável.
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 | - | o nome do arquivo a ser aberto
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 o modo de fluxo aberto. Ele é o tipo de máscara de bits, as seguintes constantes são 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 | - | outro fluxo de arquivo para usar como fonte
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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Exemplo
#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));
}
