I have come to a question in C++ Primer (p 314 , exercise 8.1) that is\nnot clear to me.\n"Write a function that takes and returns an istream&. The function\nshould read the stream until it hits end-of-file. The function should\nprint what it reads to the standard output. Reset the stream so that it\nis valid before returning the stream."\n\nBreaking this down, the function has to do three things:\n\n1. Read a stream until it hits end-of-file\nSo the >> operator reads input from an istream object - cin.\nThis stream's end of file can be interrogated by\ncin.eof(). This returns true if the end of file bit is set which can be\ntested with a bool variable\nbool on = false;\non = cin.eof();\nif(on == true)\n// end of file is reached, else\nif(on ==false)\n// keep reading cin\n\nI don't believe that this is completely correct so can someone show me\nhow this code should be presented?\n\n2. Print what is read to the standard output\nI can only imagine this to be cout << ? But am lost from here\n\n3. Reset the stream so it is valid before returning the stream\nThis section of the problem again defeats me.\n\nCan anyone help with this function?