CC> I've a little experience with java style exceptions, but none wi
CC> I need to alter the ifstream to throw an exception once an end o
CC> file is reached.
CC> EG.
CC> MYifstream.get(char c) {
CC> ifstream::get(c);
CC> if (ifstream::gcount()==0) {
CC> "thow end of file exception"
CC> }
CC> }
Don't do this! An input stream isn't supposed to throw an exception on
end of file. There is no good reason for it, since eof isn't an
exceptional situation.
Rather rewrite
CC> try {
CC> do { ifs.get(c); } while (c==' ');
CC> } catch {
CC> "end of file" exception
CC> } finally {
CC> ...
CC> }
to
char c;
while (ifs.get(c) && c!=' ');
if (ifs.eof())
// do your 'exceptional' stuff here
else
// do your 'normal' stuff here
Thomas
---
þ MM 1.0 #0113 þ I couldn't repair your brakes, so I made your horn louder.
---------------
* Origin: McMeier & Son BBS (2:301/138)
|