Answers to Self-Review Exercises

  1. 16.1

    1. True.

    2. False. Standard Library algorithms are not member functions. They operate indirectly on containers, through iterators.

    3. True.

    4. False. Standard Library algorithms do not depend on the implementation details of the containers on which they operate.

    5. True.

    6. False. It locates only the first value in the range for which the specified unary predicate function returns false.

    7. True.

  2. 16.2

    1. Iterators.

    2. random-access.

    3. fill, fill_n.

    4. equal.

    5. minmax_element.

    6. push_back.

    7. function object.

  3. 16.3

    1. fill(items.begin(), items.end(), "hello");

    2. generate(integers.begin(), integers.end(), nextInt);

    3. bool result{equal(strings1.cbegin(), strings1.cend(), strings2.cbegin())};

    4. auto newEnd remove_if(colors.begin(), colors.end(), startsWithBL); ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.