Quote:Original post by Koshmaar
better to say that I prefer to check for null instead :-)
really, so you would rather have branching code via an if-statement that executes every time it reaches that statement rather than having no normal branching code at all and only handle the exceptional case when it actually does happen, i know which i prefer [smile]
Quote:Original post by Auron
Note that dynamic memory is not deallocated when an exception is thrown unless you explicitly do so. This means that you may have to implement handlers at multiple levels whose only purpose is to clean up then throw the exception up to the next level of the call stack.
The problem is you can't always release resources if its not seen in the scope of the catch statement, this is where you need to employ RAII techniques.
Exception Handling in C++ is a little flawed, it was introduced late into the language and wasn't taken very far (as Bjarne's describes in the design of c++), languages such as java do exception handling better. Thats not to say don't use it or its unusable its just to say things like a finally statement would help alot, its still better than doing needless error codes that make you write endless amount of if statements that is completely unneccessarily executated for about 99% of the time (prime examples win32 lib, dx).
Excetion Handling is good for library writers & library users as library users know what should happen in a particular situation in are apps not the library.