Alex Rivera | Logout

what is a domain error

Asked 2009-03-13T00:41:52.703
19

in c++, <stdexcept> has a base class for 'domain errors', std::domain_error. i don't understand under what circumstances i should throw a domain error in my code. all of the other exception base classes are pretty self explanatory. i'm pretty sure that std::domain_error has nothing to do with internet domain names, per se, so please explain what class of error a domain error is and provide some examples.

Edit
Report

1 Answer

2

Pretty good explanation form cplusplus.com:

Generally, the domain of a mathematical function is the subset of values that it is defined for. For example, the square root function is only defined for non-negative numbers. Thus, a negative number for such a function would be a domain error.

answered 2009-03-13T00:47:08.133

Your Answer