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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started