Inherited Code Discussions | C++ | HackerRank

Inherited Code

  • + 0 comments

    why do we have to inherit exception why cant we do it like as below?

    class BadLengthException { int length;

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

    };