You are viewing a single comment's thread. Return to all comments →
I cannot see the proper solution where we inherit all methods. So, here it is:
class BadLengthException : public exception { private: string message; public: BadLengthException(const int& msg) : message(to_string(msg)) {} const char* what() const noexcept override{ return message.c_str(); } };
To be syntactically coherent with error messages, we need to return the error as a C-style string, not an integer.
Seems like cookies are disabled on this browser, please enable them to open this website
Inherited Code
You are viewing a single comment's thread. Return to all comments →
I cannot see the proper solution where we inherit all methods. So, here it is:
To be syntactically coherent with error messages, we need to return the error as a C-style string, not an integer.