VC++容器调试
发布网友
发布时间:2024-10-07 01:13
我来回答
共1个回答
热心网友
时间:2024-12-10 01:54
提示你out of range,是超出范围了。也就是容量100个元素,你去取第200个元素了。
The max_size() function returns the maximum number of elements that the
container can hold. The max_size() function should not be confused with
the size or capacity
functions, which return the number of elements currently in the
container and the the number of elements that the container will be able
to hold before more memory will have to be allocated, respectively.
max_size是容器最大的容量。size()是当前元素数量。capacity是已经给容器分配的空间里,还有多少剩余空间。(没有达到max_size之前,容器可能会多次分配空间(按照2的倍数分配空间))