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.
What I've learned:
1. In try-catch structure, throw passes a value to the catch section.
Class(arg) also can create object of the class "Class" called "arg"?? I thought I could use a parameterized constructor to get the letter length and override what() method to print it out. I'm still wandering how's it possible for my exception class to accept the letter number "n".
"exception" header imports "exception" base class. We can define our own exception class ourselves.
classBadLengthException:publicexception{private:intn;// override what() to return the letter lengthpublic:BadLengthException(intlength){n=length;}intwhat(){returnn;}};
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Inherited Code
You are viewing a single comment's thread. Return to all comments →
What I've learned: 1. In try-catch structure, throw passes a value to the catch section.
Class(arg) also can create object of the class "Class" called "arg"?? I thought I could use a parameterized constructor to get the letter length and override what() method to print it out. I'm still wandering how's it possible for my exception class to accept the letter number "n".
"exception" header imports "exception" base class. We can define our own exception class ourselves.