We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Classes
- Inherited Code
- Discussions
Inherited Code
Inherited Code
Sort by
recency
|
223 Discussions
|
Please Login in order to post a comment
class BadLengthException{ public: int n; BadLengthException(int e){ n=e; } int what() { return n; } };
If showing error in integer or const something stuffs, just remove the 'const' keyword after as : class BadLengthException : public exception { private: int exceptionname; public: explicit BadLengthException(const int &exceptionexample) { exceptionname = exceptionexample;}
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.
what defines if something is invalid???
try c++14 class BadLengthException : public exception{ private: int length; public: BadLengthException(int n){ length=n; } int what(){ return length; } };