std::ios_base::failure
来自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. |
| Defined in header <ios>
|
||
| class failure; |
||
類std::ios_base::failure在失敗時拋出一個異常對象,是由輸入/輸出庫中的函數定義.
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.
目錄 |
[编辑] 成員函數
| 構造異常對象 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. (公共成員函數) | |
Inherited from std::system_error
Member functions
| 返回錯誤代碼 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)
| |
| [虛擬的] </ SPAN></div></div>
|
返回解釋性字元串 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)
|
</div>
Inherited from std::runtime_error
Inherited from std::exception
Member functions
| [虛擬的] </ SPAN></div></div>
|
解構異常對象 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)
|
| [虛擬的] </ SPAN></div></div>
|
返回一個說明字元串 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)
|
</div>
[编辑] 為例
#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'; } }
Output:
Caught an ios_base::failure. Explanatory string: ios_base::clear: unspecified iostream_category error Error code: iostream:1
[编辑] 另請參閱
| (C++11) |
IO流的錯誤代碼 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. (枚舉) |
