std::ios_base::failure
Da cppreference.com
![]() | This page has been machine-translated from the English version of the wiki using Google Translate. The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Definido no cabeçalho <ios> | ||
class failure; | ||
O std::ios_base::failure classe define um objeto de exceção que é acionada em caso de falha as funções na entrada / saída da biblioteca.
Original:
The class std::ios_base::failure defines an exception object that is thrown on failure by the functions in the Input/Output library.
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.
Índice |
[editar]Funções de membro
constrói o objeto de exceção Original: constructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |
Herdado de std::system_error
Member functions
retorna código de erro Original: returns error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::system_error função pública membro) | |
[virtual] | Retorna a string explicativo Original: returns explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::system_error função pública virtual membro) |
Herdado de std::runtime_error
Herdado de std::exception
Member functions
[virtual] | destrói o objeto de exceção Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::exception função pública virtual membro) |
[virtual] | retorna uma cadeia explicativa Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::exception função pública virtual membro) |
[editar]Exemplo
#include <iostream>#include <fstream>int main(){std::ifstream f("doesn't exist");try{ f.exceptions(f.failbit);}catch(const std::ios_base::failure& e){std::cout<<"Caught an ios_base::failure.\n"<<"Explanatory string: "<< e.what()<<'\n'<<"Error code: "<< e.code()<<'\n';}}
Saída:
Caught an ios_base::failure. Explanatory string: ios_base::clear: unspecified iostream_category error Error code: iostream:1
[editar]Veja também
(C++11) | O erro de IO códigos de fluxo Original: the IO stream error codes The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (enum) |