Quote:
Originally posted by abc_coder
it's the intended behavior. Constructors don't return error codes so if you do a one-step (i.e. in the constructor) initialization of some resource and that fails, the most dirrect way of announcing the failure is by throwing an exception. (there are other less direct ways too, but you have to revert to C-style error checking)
also, to handle the cleanup (if you're throwing from a constructor, *this is not completely constructed and thus the destructor won't be called), constructor initializers are handy: any subobjects will be in a definite state and will be handled nicely by the exception cleanup procedure.
Thanks a lot,