Starting up

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

My Web site is here http://www.teslacore.it

Comments

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:

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

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


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

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 from this blog

Docker for our ROS robotic overlords

cmakego: Simpler access to external libraries in CMake

Algebrical Data Types in C++