Problem passing in istream argument to a class constructor?

The problem is that istream is an "interface". It has pure virtual functions, so it doesn't make sense to have a copy of it. What you might do is to keep a reference to the passed stream.

The problem is that istream is an "interface". It has pure virtual functions, so it doesn't make sense to have a copy of it. What you might do is to keep a reference to the passed stream: std::istream& strm_; strm_ could be ifstream or istringstream or any input stream derived from istream.

You can't copy-construct a stream because the base-class ios has its copy ctor private. Try making the stream member a reference, rather than a standalone object.

You are trying to store a copy of the stream. This will not work, since streams are not copyable. Best you can do is store a reference or a pointer.

However, if only one method is going to use the stream, just pass a reference to this method. Other problems: while (!strm_.eof()) { strm_ >> n >> m; if (isFact(n,m)) Eof is set when an attempt to read data fails because of this. As it is you are bound to read the last entry twice.

Instead: while (strm >> n >> m ) if (isFact(n, m).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions