Inherited Code Discussions | C++ | HackerRank

Inherited Code

Sort by

recency

|

226 Discussions

|

  • + 1 comment

    This is my exception, it doesn't work on random test cases, anyone knows why ?

    class BadLengthException: public exception { private: int length;

    public:
        BadLengthException(int len) : length(len) {}
    
        virtual const char* what() const noexcept {
            stringstream ss;
            ss << length;
            return (ss.str().c_str());
        }
    

    };

  • + 0 comments

    Here is Inherited Code problem solution in C++ - https://programmingoneonone.com/hackerrank-inherited-code-solution-in-cpp.html

  • + 0 comments

    I'm also facing this issue on my dunkin donuts menu site.

  • + 0 comments

    class BadLengthException{ public: int n; BadLengthException(int e){ n=e; } int what() { return n; } };

  • + 0 comments

    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;}

    int what()    // removing 'const' after 'what()' works , not any other
    {       
        return exceptionname;
    }