Export (0) Print
Expand All

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);
    explicit domain_error(const char *message);
};

The value returned by exception Class is a copy of message.data.

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

Header: <stdexcept>

Namespace: std

Show:
© 2015 Microsoft