Mail Archives: djgpp/1997/11/04/11:45:46
Nate Eldredge wrote:
> *Are* files Supposed to work in destructors?
If they don't there's something very wrong with the
C++ specification. Think of a database class - you
want it to close the database tidily before it
disappears. I hadn't noticed this behaviour before
because the only files I close in the dtor are in
dynamic instantiations of the classes (either deleted
explicitly or in inner blocks.
I'll see if I can find any mention of it in Stroustrup
tonight.
Of course, if you use the iostream library then that
should behave properly, closing the file only when you
delete the stream object. Does this work?
Chris C
- Raw text -