The exception of C ++ comes. The return value of the C era is a poor waste in the C ++ era.
Benefits of exceptions:
1. As long as you use C ++, you will inevitably encounter exceptions. STL or simple new may run out of exceptions at any time. If you want to write a robust enoughProgram, You must handle the exception! Since sooner or later Exception Processing is required, we should enjoy the exception. Why is it so troublesome to judge the return value of a function?
2. Usage exception. YourCodeIt will be able to get along with STL, because each other is so fond of throwing exceptions, so it is very easy to resonate. STL like to get objects directly, but what your code gives STL is a return value indicating success or failure, which makes STL feel inferior. Yes, STL wants to get you, but you tell STL that you are doing the right thing. This will make people quite speechless and lead to difficulties in communication.
3. Usage exceptions reduce the amount of code, optimize labor efficiency, reduce coding time, spend more time with family members and children, promote feelings, and enjoy a better life.