I have to program a function which validates a number by reading a text file line by line. My problem is that this is a const stream. I thought that creating a new stream would help but my code is not compiling correctly.
bool validateNumber(const std::istream& n_is)
{
while (!n_is.eof())
{
std::string line;
std::istream test = n_is;
std::getline(test,line); // read line
I get this error message:
/usr/include/c++/5/bits/ios_base.h:855:5: error: ‘std::ios_base::ios_base(const std::ios_base&)’ is private.
What should I do to be able to read the stream even though it is const?