#include
#include
#include
#pragma warning(disable:4996)
using namespace std;
void test10()
{
vector<int> v1;
cout << "容量" << v1.capacity() << "大小:" << v1.size();
vector<int>::iterator it;
int i = 0;
int count = 0;
for (i = 0; i < 1000; i++)
{
v1.push_back(i);
if (it != v1.begin())
{
count++;
cout << "第" << count << "次开辟空间容量:" << v1.capacity() << endl;
it = v1.begin();
}
}
}
int main() {
test10();
return 0;
}
容器pushback后,迭代器it会失效