Determine if there are any errors in the following programs and, if so, correct the error(s):
(a) vector
vec; list lst; int i; while (cin >> i)
lst.push_back(i);
copy(lst.cbegin(), lst.cend(), vec.begin());
(b) vector
vec; vec.reserve(10); // reserve is covered in § 9.4 (p. 356)
fill_n(vec.begin(), 10, 0);
Exercise 9.31
The program on page 354 to remove even-valued elements and duplicate odd ones will not work on a list or forward_list. Why? Revise the program so that it works on these types as well.
Exercise 9.32
In the program onpage 354 would it be legal to write the call to insert as follows? If not, why not?
iter = vi.insert(iter, *iter++);
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.