what is a domain error

后端 未结 7 1613

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 20:02

    A domain error refers to issues with mathematical domains of functions. Functions are sometimes defined only for certain values. If you try to invoke such a function with an argument that is not part of its domain, that is a domain error.

    For example, trying to invoke sqrt() with a negative argument is a domain error, since negative numbers are not part of the domain of sqrt().

提交回复
热议问题