Cisco Interview Question

How would you implement the try/finally construct in C++?

Interview Answer

Anonymous

Apr 15, 2014

via destructor of scoped object. I would create a dummy object in "try" scope, and put the "finally" code inside the destructor of that object. Since DTOR is guranteed to be called it will always perform the "finally" statements