共用方式為


domain_error Class

The class serves as the base class for all exceptions thrown to report a domain error.

class domain_error : public logic_error {
public:
       explicit domain_error(const string& message);
};

Remarks

The value returned by what is a copy of message.data.

Example

// domain_error.cpp
// compile with: /EHsc /GR
#include <iostream>

using namespace std;

int main( )
{
   try 
   {
      throw domain_error( "Your domain is in error!" );
   }
   catch (exception &e) 
   {
      cerr << "Caught: " << e.what( ) << endl;
      cerr << "Type: " << typeid(e).name( ) << endl;
   };
}

Caught: Your domain is in error!
Type: class std::domain_error

Requirements

Header: <stdexcept>

Namespace: std

See Also

Concepts

<stdexcept> Members

logic_error Class

Thread Safety in the Standard C++ Library