My question is how,
while(cin>>x) {
Job. Or, to be more specific, how about this code stops the loop?
From the documentation here , it seems that the → operator returns a &istream . Does this mean that if the reading failed or is at the end of the file, it not only sets eofbit, failbit or badbit, but also returns zero? It doesn’t make sense, so I doubt it.
Is there some kind of implicit eofbit check?
I ask because I hope to implement something similar with 2 classes such as
class B {
Note. I do not want to inherit from istream , unless there is magic where this work comes from. The reason for this is because I hope to keep as few classes and their dependencies as possible. If I inherit from istream , I will get all my public and protected things, and I am not trying to create an istream object. I just want to copy one REALLY good piece.
Edit: I am using Visual Studio 2010 (which becomes a real pain), and I will need something compatible with it implementation of C ++ 03 + some C ++ 11.
Dan
source share