what is a domain error

后端 未结 7 1603

in c++, 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

7条回答
  •  醉酒成梦
    2021-02-05 19:55

    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.

提交回复
热议问题