एक अच्छा अभ्यास, आपके आवेदन अपवाद के अपने स्वयं के सेट, लागू नहीं किया गया विधि के लिए एक सहित परिभाषित करने के लिए के लिए किया जाएगा। सुनिश्चित करें कि आप अपने अपवाद प्रकार को std::exception से प्राप्त करते हैं ताकि अपवाद फेंकने वाले कार्यों के कॉलर्स एक समान तरीके से त्रुटि को पकड़ सकें।
बस एक संभव तरीके से एक NotImplementedException लागू करने के लिए:
class NotImplementedException
: public std::exception {
public:
// Construct with given error message:
NotImplementedException(const char * error = "Functionality not yet implemented!")
{
errorMessage = error;
}
// Provided for compatibility with std::exception.
const char * what() const noexcept
{
return errorMessage.c_str();
}
private:
std::string errorMessage;
};
नहीं - std :: अपवाद फेंक दें ("लागू नहीं किया गया") –
@ डाइटर लुकिंग std :: अपवाद में एक स्ट्रिंग सीटीओआर है? – nurettin
@nurettin right, इसमें कोई नहीं है - std :: logic_error उचित हो सकता है –