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
+ 0 comments - struct BadLengthException{ int n; BadLengthException(int n){ this->n = n; } int what(){ return n; } };
+ 0 comments C++14 per API that derives from
std::exception
instead of a free-floatingclass
/struct
.class BadLengthException : exception { public: BadLengthException( int length ) : message_(to_string(length)) {} const char* what() const noexcept override { return message_.c_str(); } private: string message_; };
+ 1 comment I kept it as a struct, since that is what was provided. For those that may not already know, a struct is essentially the same as a class - only that it is 'public' by default, opposed to classes which are 'private' by default.
solution
struct BadLengthException{ int n; BadLengthException(int n){ this->n = n; } int what(){ return n; } };
+ 0 comments class BadLengthException { int n=0; public: BadLengthException(int x){ n+=x; } int what(){ return n; } };
+ 1 comment As part of a Tech Base website I'm creating tool-based websites like mouse tests using C++. Can anyone help me or guide me through this process?
Load more conversations
Sort 203 Discussions, By:
Please Login in order to post a comment