K
khapi
Hi folks,
I noticed that the standard library has a bunch of
subclasses like std::bad_alloc, std::runtime_error
that derive from std::exception.
I gather that in order to use one of these error
subclasses, one creates an instance of that subclass,
using whichever one is appropriate.
But is this really a good design practice?
It seems odd that the creators of std chose subclasses
for different situations. Why didn't they create
methods for each situation instead?
Thanks.
I noticed that the standard library has a bunch of
subclasses like std::bad_alloc, std::runtime_error
that derive from std::exception.
I gather that in order to use one of these error
subclasses, one creates an instance of that subclass,
using whichever one is appropriate.
But is this really a good design practice?
It seems odd that the creators of std chose subclasses
for different situations. Why didn't they create
methods for each situation instead?
Thanks.