Hey guys...Can you please help me explain what does returning an istream object mean.
I am currently studying Accelerated C++ and at many places a function returns istream object. What does it mean?
For example:-
istream& read(istream& is, Student_info& s)
{
// read and store the student's name and midterm and final exam grades
is >> s.name >> s.midterm >> s.final;
read_hw(is, s.homework); // read and store all the student's homework grades
return is;
}
istream& read_hw(istream& in, vector<double>& hw)
{
if (in) {
// get rid of previous contents
hw.clear() ;
// read homework grades
double x;
while (in >> x)
hw.push_back(x);
// clear the stream so that input will work for the next student
in.clear();
}
return in;
}
What do the two functions mean? Basically, I want to ask what does passing an istream object mean and returning an istream object do?
And they are using "is" with ">>". Isn't cin used there?