次の方法で共有


domain_error Class

 

The latest version of this topic can be found at domain_error Class.

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

Syntax

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

    explicit domain_error(const char *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;  
   };  
}  
\* Output:   
Caught: Your domain is in error!  
Type: class std::domain_error  
*\  

Requirements

Header: <stdexcept>

Namespace: std

See Also

logic_error Class
Thread Safety in the C++ Standard Library