What happens if an exception occurs in a destructor in C++? 

  • The program will retry the destructor 
  • A default destructor is called 
  • The program terminates 
  • The exception is ignored
If an exception is thrown from a destructor, and it's not caught within the destructor, the C++ runtime system will terminate the program. Destructors are often invoked during stack unwinding when an exception is thrown, so allowing exceptions to propagate out can lead to unpredictable behavior.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *