Aracılığıyla paylaş


ios_base::failure

Sınıf failure özel durumlar işlevleri tarafından atılan tüm nesne türleri için temel sınıf tanımlar iostreams kitaplığı, Akış Arabellek işlemleri sırasında algılanan hataları raporlamak için.

namespace std {
    class failure : public system_error {
    public:
        explicit failure(
            const string& _Message, 
            const error_code& _Code = io_errc::stream
        );
        explicit failure(
            const char* _Str, 
            const error_code& _Code = io_errc::stream
        );
};

Notlar

Tarafından döndürülen değeri what() 'in _Message, büyük olasılıkla artmış temel sınama ile _Code._Code Belirtilmezse, varsayılan değer olan make_error_code(io_errc::stream).

Örnek

// ios_base_failure.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>

int main ( ) 
{
   using namespace std;
   fstream file;
   file.exceptions(ios::failbit);
   try 
   {
      file.open( "rm.txt", ios_base::in );
      // Opens nonexistent file for reading
   }
   catch( ios_base::failure f ) 
   {
      cout << "Caught an exception: " << f.what() << endl;
   }
}
  

Gereksinimler

Başlık: <ios>

Namespace: std

Ayrıca bkz.

Başvuru

ios_base Class

system_error Class

iostream programlama

iostreams kuralları