C++ Pitfalls 之 reference to an object in a dynamically allocated containter

(留坑待填)

 Extraction from the C++ Programming Language 4th. ed., Bjarne Stroustrup

31.3.3 Size and Capacity

The size is the number of elements in the container; the capacity is the number of elements that a container can hold before allocating more memory.

When changing the size or the capacity, the elements may be moved to new locations. That implies that iterators (and pointers and references) to elements may become invalid (i.e., point to the old element locations).

 

posted @ 2016-08-29 22:25  Pat  阅读(191)  评论(0编辑  收藏  举报