I read this on Accelerated C++. Here is a simplified version.
istream& read_hw(istream& in, Student_info& s)
{
in >> s.name >> s.midterm >> s.final;
return in;
}
Then, we can call the function as:
Student_info s;
read_hw(cin, s);
My question is,
- What’s the point of returning the reference to istream? Since both the two parameters are passed by reference;
- While calling the function, we don’t seem to care about the returning value
You should read the next paragraph: