devxlogo

Ensuring Proper Cleanup in the Case of an Uncaught Exception

Ensuring Proper Cleanup in the Case of an Uncaught Exception

It is implementation-dependent whether the destructors of local objects are invoked when an uncaught exception occurs. To ensure that destructors of local objects are invoked in this case, you can add a catch-all statement in main() like this.

 int main(){  try  {    //

devx-admin

Share the Post: