Write the overloaded functions void readVector(istream & is, Vector & vec); void readVector(istream & is, Vector &
Question:
Write the overloaded functions
void readVector(istream & is, Vector & vec);
void readVector(istream & is, Vector & vec);
void readVector(istream & is, Vector & vec);
each of which reads lines from the input stream specified by is into the vector vec. In the input stream, each element of the vector appears on a line of its own. The function should read elements until it encounters a blank line or the end of the file. To illustrate the operation of this function, suppose that you have the data file
and that you have opened in file as an if stream on that file. In addition, suppose that you have declared the variable roots as follows:
Vector roots;
The first call to read Vector(in file, roots) should initialize roots so that it contains the four elements shown at the beginning of the file. The second call should change the value of roots so that it contains the eight elements shown at the end of the file. Calling read Vector a third time should set roots to an empty vector.