std::ios_base::failure

来自cppreference.com

 
 
輸入/輸出庫
I / O操縱
C-風格的I / O
緩衝區
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(過時了)
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
抽象
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
文件I / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
字元串I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
陣列的I / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(過時了)
ostrstream(過時了)
strstream(過時了)
類型
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
Error類的介面
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
ios_base::failure
成員函數
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.
failure::failure
 
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.
cpp/error/exceptionstd-ios base-failure-2003-inheritance.svg
關於這幅圖像

Inheritance diagram (至 C++11)

cpp/error/exceptioncpp/error/runtime errorcpp/error/system errorstd-ios base-failure-inheritance.svg
關於這幅圖像

Inheritance diagram (C++11 起)

目錄

[编辑] 成員函數

構造異常對象
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.

(公共成員函數) [edit]

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 [edit]
[虛擬的] </ 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 [edit]

</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 [edit]
[虛擬的] </ 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 [edit]

</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.

(枚舉) [edit]

来自“http://zh.cppreference.com/mwiki/index.php?title=cpp/io/ios_base/failure&oldid=27609