Q:

Assuming c is a multiset of strings and v is a vector of strings, explain the following calls. Indicate whether each call is legal

0

Assuming c is a multiset of strings and v is a vector of strings, explain the following calls. Indicate whether each call is legal:

copy(v.begin(), v.end(), inserter(c, c.end()));
copy(v.begin(), v.end(), back_inserter(c));
copy(c.begin(), c.end(), inserter(v, v.end()));
copy(c.begin(), c.end(), back_inserter(v));

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Assume `multiset<string> c; vector<string> v;`, then

copy(v.begin(), v.end(), inserter(c, c.end()));

is OK.

copy(v.begin(), v.end(), back_inserter(c));

is error. A `multiset` doesn't have `push_back` memeber function.

copy(c.begin(), c.end(), inserter(v, v.end()));

is OK.

copy(c.begin(), c.end(), back_inserter(v));

is OK.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now