Inherited Code Discussions | C++ | HackerRank

Inherited Code

  • + 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());
        }
    

    };