what is a domain error

后端 未结 7 1450

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:54

    Well, this is all the guidance you get from the C++ standard:

    The class domain_error defines the type of objects thrown as exceptions by the implementation to report domain errors.

    Domain here means "problem domain", nothing to do with the internet. For example, a square root function might throw a domain error if passed a negative number.

提交回复
热议问题