# Answer to Question #58452 in C++ for jonney

Question #58452

Consider the template class List presented in the course (slide set

“Templates”, section “Generic Lists”). Write a template function read such that

the following operation becomes possible:

bool isend(double x) { return x == 0; }

List<double> l;

int n = read<double,isend>(l);

The function reads a sequence of items x1, . . . , xn+1 such that n + 1 is the smallest

i for which isend(xi) returns true and puts the elements x1, . . . , xn (in the order

in which they were read) into l. The result of the function is n, if everything went

okay, and −1, if an error occurred.

You may modify the definition of List, e.g. by adding new data members and/or

member functions (please indicate your changes clearly).

“Templates”, section “Generic Lists”). Write a template function read such that

the following operation becomes possible:

bool isend(double x) { return x == 0; }

List<double> l;

int n = read<double,isend>(l);

The function reads a sequence of items x1, . . . , xn+1 such that n + 1 is the smallest

i for which isend(xi) returns true and puts the elements x1, . . . , xn (in the order

in which they were read) into l. The result of the function is n, if everything went

okay, and −1, if an error occurred.

You may modify the definition of List, e.g. by adding new data members and/or

member functions (please indicate your changes clearly).

Expert's answer

#### Answer in progress...

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment