SystemException class is the base class for all predefined system exception.
Exception handlers have disadvantages. If a function does not return because it, or some other function it called, threw an exception, data might be left in an inconsistent state. You need to know when an exception might be thrown, and whether the exception might have a bad effect on the program state.
The BaseException is the base class of all other exceptions. User defined classes cannot be directly derived from this class, to derive user defied class, we need to use Exception class.
All exception and error types are subclasses of class Throwable, which is the base class of the hierarchy.
I'm doing the exercises from Stroustrup's C++ Programming Language 4th Edition. One of the tasks is formulated like this:
Consider using a class Exception as the base of all classes used as exceptions. What should it look like? How should it be used? What good might it do? What disadvantages might result from a requirement to use such a class?
The answer looks pretty much like std::exception
, save for the disadvantages part - the only one I can imagine is the cost of __vptr
which is usually considered negligible. What am I missing here?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With