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
A good practice would be for your application to define its own set of exceptions, including one for unimplemented method, if that is needed. Make sure you inherit your exception type from std::exception so that callers of exception throwing functions can catch the error in a uniform way.
Just one possible way to implement a 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;
};