Partager via


ios_base::failure

The member class serves as the base class for all exceptions thrown by the member function clear in template class basic_ios.

class failure : public runtime_error {
public:
     explicit failure(
          const string& _Message)
     };

Remarks

The value returned by the member function what() is _Message.c_str().

Example

// 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;
   }
}

Caught an exception: ios_base::failbit set

Requirements

Header: <ios>

Namespace: std

See Also

Concepts

ios_base Class

ios_base Members

iostream Programming

iostreams Conventions