C ++是否有相当于.NET的NotImplementedException? [英] Does C++ have an equivalent to .NET's NotImplementedException?

查看:125
本文介绍了C ++是否有相当于.NET的NotImplementedException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++的标准库是否包含与.NET的NotImplementedException异常相同的异常?

Does the standard library of C++ contain an exception equivalent to .NET's NotImplementedException?

如果没有,处理我打算完成的不完整方法的最佳做法是什么?

If not, what are the best practices to handle incomplete methods that I intend to complete later on?

推荐答案

您可以继承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/

这篇关于C ++是否有相当于.NET的NotImplementedException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆