103. Destructors-I

Question.5

A developer throws an exception inside a destructor:

class FileWriter {
   FILE* f;
public:
   FileWriter() : f(fopen("log.txt","w")) {}
   ~FileWriter() {
       if (fclose(f) != 0)
            throw std::runtime_error("Close failed");
   }
};

What happens if the exception is thrown during stack unwinding (while another exception is being handled)?

Need Help? Refer to the Quick Guide below

Select Answer