// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <string>

using namespace std;

class X
{
private:
    string id;
public:
    X(string id) { this->id = id; cout << "Allocate " << id << endl; }
    virtual ~X() { cout << "Deallocate " << id << endl; }
};

void f2()
{
   throw "Houston we have a problem";
}

void f1()
{
   X o2("o2");
   X *o3 = new X("o3");
   f2();
   delete o3;
}

int main()
{
    try
    {
        X o1("o1");
        f1();
    }
    catch(char *ex)
    {
        cout << ex << endl;
    }
    return 0;
}

