You cannot do this because an abandoned object can be of any possible type, including plain old data such as int or double. It is not possible to infer its actual type.
Even if the language gave you a pointer to an object, you still cannot use anything with it, at least not in a safe type. It will be like emptiness * of unknown data. You can try RTTI, but then you can just as well catch the type that you will test.
Any useful action for an abandoned object involves accepting an assumption about its type, for example, a common base class (for example, std::exception or myapp::object ), which allows you to actually catch this type, creating a common catch(...) not necessary.
Usually the least thing to do when catching an exception is to print a message. This is why it is a good idea to get exceptions from std :: exception, which provides this message through the what () function. This eliminates the need for a catch (...).
source share