Post by Alex WalterPost by Zikun Xuis there some difference between istream and ifstream?
ifstream is a subclass of istream
Although Alex is right I'd like to elaborate a little more on this
because it's likely you haven't seen this before.
Basically an ifstream is a specific kind of istream. Istream is a
general input stream class, and ifstream works on files (that's what the
f is for). This means that the things you want to do with an istream
like reading in characters or lines works the same way as on an
ifstream, but some file specific things like opening or closing files
will not work on an istream as it's not that specific.
What's going on will make a lot more sense in a few weeks, but for now
just think of them as the same thing except that an ifstream can do the
file-specific operations you might need, but it can't work with cin
(because that's not a file) and an istream will work for cin, and a
pointer to an istream can point to either an istream or an ifstream.
--
-------------------------------------------------
John Munnings
CS 246 Tutor
School of Computer Science, UW
Office: DC3128
-------------------------------------------------