Inherited Code Discussions | C++ | HackerRank

Inherited Code

Sort by

recency

|

221 Discussions

|

  • + 0 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.

  • + 0 comments

    what defines if something is invalid???

  • + 0 comments

    try c++14 class BadLengthException : public exception{ private: int length; public: BadLengthException(int n){ length=n; } int what(){ return length; } };

  • + 0 comments

    How could i know if it valid or not valid or short ??????

  • + 0 comments

    when im trying to solve the code in c++20 im not receiving any prior code, how do i fix this can someone please help me out