Does overloaded istream operators overload ifstream as well?
Hey, all! It's been a while. I am having a strange problem which doesn't seem right. I have a class I created that I am trying overload the insertion operator (>>). I do so with this code:
Inside the main/driver program code I open and read the data from a file. However, when I use the insertion op (>>), it doesn't read anything from the file. It will read the data in from the keyboard (i.e. it overloads fine with cin), however it gets nothing from a file. The file opens fine and the data is structured ok. I always thought that an ifstream object was also considered an istream.
istream &operator>>(istream &in, Student &studentcopy)
in >> studentcopy.ssn >> studentcopy.creditsToDate >> studentcopy.pointsToDate;
I also created another overloaded operator function but instead of istream I made it ifstream. Still nothing, though. Anyone have any ideas? Thanks