Why do you think the algorithms don’t change the size of containers
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:10| Question number:10
All Answers
total answers (1)
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:10| Question number:10
total answers (1)
We pass only iterators to algorithms, not containers, so the algorithms have no direct access to the container members. If we want change the size of a container, we must do it by calling the cotainer members. Thus the algorithms cannot change the size of containers.
Insert iterator, however, has access to container members when we pass the container to it. Thus it can change the size of containers.