int main() { //如何正确的删除所有元素 循环 int a[]={1,2,3,4,5,6,7,8,9}; vector<int> v(a,a+6); for(vector<int>::iterator it=v.begin();it!=v.end();) { it=v.erase(it); } for(vector<int>::iterator it=v.begin();it!=v.end();it++) { cout<<*it<<endl; } cout<<v.size()<<endl; getchar(); return 0; }
原文地址:http://blog.csdn.net/cq361106306/article/details/39668595