[Question] What happens if you close the window (or there is a crash) with a ostream open?

So, I made a debug class. It works just like std::cout and other streams. I just do "debug << SomeMessage<< endl;" and it then debugs the proper code to the proper locations, assuming debugging is turned on. The implementation checks if debugging is on and then outputs it to the console and a log file. I open the file with ostream in the constructor and close it in the deconstructor (to make sure it is closed). When the user clicks close, presses ALT-F4 or the program crashes, does it still run this deconstructor and close the file?

I am doing WIN32.
1) If user closes the program or exception is trown, destructors for existing objects are called automatically.
2) If program stops working some other way, and if you using buffered output, it cold be not flushed properly and some data lost.
So, I should be safe then? Awesome. Thanks.
Topic archived. No new replies allowed.