catch(...) { cout << "an exception was thrown" << endl; // Deallocate your resource here, and then rethrow throw; }