Starting up

Here start Sanka Blog about ... who knows, maybe travelling and programming.

My Web site is here


Massimiliano said…
Sanka Blog? With pictures and programming news? Good!
This is my first post.. How i inserted try.. finally clause in c++..

Suppose you want to insert a finally clause that dealcate all alocated memory. It can be usefull if you don't want to replicate code for deallocation..

Code snippet:

//your code.. may throw exception during execution
// some memory allocation and other stuff...

//code for execution recovery or failure management
throw -1;
throw 0;
catch(int finallyvalue)
//do something.. no error occurred
//do something else.. error occurred end exception trapped

I hope that this code could be usefull...
Please, visit my blog:

See ya!
Answering to the issue on try ... finally in C++ by Max the problem is that in this way you are not able to intercept well other kinds of eceptions.

The best way to implement the finally construct is to use a support object whose destructor is invoked on exiting the try ... catch scope. The most common case of finally code si the one relative to resource deallocation. Call-it a resource holder pattern.

Popular Posts