Question: Write the overloaded functions void readVector(istream & is, Vector & vec); void readVector(istream & is, Vector & vec); void readVector(istream & is, Vector & vec);

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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!