Hi, > Naaaa, throwing from a constructor is fine. Throwing from a destructor > is a big no no. Actually there is no other way to cleanly 'get out' > when construction fails.
Ooohh... big disagreement coming up here!! Consider this line: Foo *foo = new Foo(); Assuming 'new' succeeds and allocates memory on the heap: if the constructor throws, the pointer 'foo' never gets initialised. How do you cleanly 'get out' of that one? I.e. how do you delete the allocated memory without knowing where it is? If someone has a solution for this, I'll happily change my position! My opinion is that it is a question of design, and that any initialisation which throws on error must be performed post-construction in a separate step, such as foo->init() or so. Going back to Den's original post, that means he'd need to add an init method to ImageModel, and make sure it gets called when he wants to use the object. Steve
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
