67 030
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #58337 in C++ for jonney

Question #58337
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 index i
for which isend(xi) returns true; the function 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. The function needs time O(n).
You may modify the definition of List, e.g. by adding new data members and/or member
functions (please indicate your changes clearly); in particular, since new elements are to
be added at the end of the list, it is recommended to keep track of its last element.
Expert's answer

Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions