www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/04/11:45:46

Sender: crough45 AT amc DOT de
Message-Id: <97Nov4.184128gmt+0100.11651@internet01.amc.de>
Date: Tue, 4 Nov 1997 17:44:20 +0100
From: Chris Croughton <crough45 AT amc DOT de>
Mime-Version: 1.0
To: eldredge AT ap DOT net
Cc: blizzar AT hem1 DOT passagen DOT se, djgpp AT delorie DOT com
Subject: Re: Writing to a file from dtor doesn't work!

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019