This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: trouble using ifstream as a class member
- From: Gerald Kroisandt <gerald dot kroisandt at fcc dot chalmers dot se>
- To: libstdc++ at gcc dot gnu dot org, withaar at wylch dot fastmail dot fm, phil at jaj dot com
- Date: Fri, 28 May 2004 10:58:13 +0200
- Subject: Re: trouble using ifstream as a class member
Hello,
I am dealing with the same problem (libstdc++ 3.3 from SuSE 8.2).
The problem is that if one has a variable of type ifstream within a
class, then the status-bits are not set to 0, if one even closes the
file and then opens it again, i.e. if one has read the file until the
eof-status-bit was set, then it does not help to write
tis.close();
tis.open(filename);
because the eof-bit is still set although tis.tellg() gives that it is
at the beginning (in my code, I first tried with tis.seekg(0) to come to
the beginning and then I saw that even closing and opening does not help
at all)!
What might help (I have found this solution yesterday evening, but not
tested totally) is:
tis.close();
tis.open(filename);
tis.clear();
So, at least to write somewhere the command tis.clear() which sets all
status-bits to 0 explicitely, but one must be careful not to use it too
often!
This problem also occurs on IBM-machines, but not on a SUN!
Hope this helps,
Gerald