not prohibited in c++, but dont throw them,
imagine a vector
if your destructor cant avoid having to throw an exception ( imagine destructor of a class providing db connections--resource managing classes) than code it to either terminate the program or just swallow the exception whichever is suitable. Swallowing is considered bas compared to termination.
things to remember:
destructors should never throw exceptions. if functions called in a destructor may throw, the destructor should catch any exceptions then tswallow them or terminate the program
if class clients need to be able to react to exceptions thrown during an operation the class should provide a refular ( i.e. no ndestructor) function that performs the operation
No comments:
Post a Comment