且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C ++是否有相当于.NET的NotImplementedException?

更新时间:2023-01-06 22:26:27

您可以继承std :: logic_error,并以这种方式定义错误消息:

You can inherit from std::logic_error, and define your error message that way:

class NotImplementedException : public std::logic_error
{
public:
    virtual char const * what() const { return "Function not yet implemented."; }
};

我认为这样做会使异常更加明确,如果这实际上是一种可能性。
引用std :: logic_error:
http://www.cplusplus.com/reference/ stdexcept / logic_error /

I think doing it this way makes catching the exception more explicit if that's actually a possibility. Reference to std::logic_error: http://www.cplusplus.com/reference/stdexcept/logic_error/