From: simon AT icpdd DOT neca DOT nec DOT com DOT au (Simon A. Crase) Subject: Problem with ofstream in class member 29 Jan 1998 01:06:31 -0800 Message-ID: <199801290000.LAA01797.cygnus.gnu-win32@mango.icpdd.neca.nec.com.au> Reply-To: simon AT icpdd DOT neca DOT nec DOT com DOT au To: gnu-win32 AT cygnus DOT com I have run into a problem with ofstream (Cygnus b18 compiler), so I wonder if anyone has seen it before and, if so, whether they have a better fix than the one I found. I have a class that looks like this: class Stuff { private: ofstream mystream; }; I open mystream with a file name, try to write to the file, & the program falls over. According to gdb, the culprit is the line: mystream << some_stuff << endl; This happens regardless of the data type of some_stuff. Last night I moved the declaration of mystream out of the class & put it into the function that was doing the writing: ofstream mystream("myfile); mystream << some_stuff << endl; mystream.close(); And the program works fine. Except I need to rework my design somewhat, as my current design looks like: 1. open the stream; 2. write to it from several differnet functions; 3. close. So I can work around the problem by: 1. Create a container; 2. Gradually add the stuff I was planning to write. 3. Open stream, pour the contents of the container into it, close stream. So, has anyone else seen this problem & come up with a better solution they would be willing to share? Simon A. Crase -- - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".