std::vector
itor1 = vec.begin();
for(itor1 = vec.begin(); itor1 != vec.end(); itor1++)
{
if(6 == *itor1)
{
itor2 = itor1;
vec.erase(itor2); //删除指定位置的元素
itor1--;
}
}
print(vec);
return 0;
}
void print(std::vector
{
std::cout<<"vector size is: "<
while(p != v.end())
{
std::cout<<*p<
}
}
// P96_example3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#include
void print(std::vector
int _tmain(int argc, _TCHAR* argv[])
{
std::vector
vec.push_back(1);
vec.push_back(6);
vec.push_back(6);
vec.push_back(3);
//删除vec数组中的所有6
std::vector
std::vector
itor1 = vec.begin();
for(itor1 = vec.begin(); itor1 != vec.end(); itor1++)
{
if(6 == *itor1)
{
itor2 = itor1;
vec.erase(itor2); //删除指定位置的元素
itor1--;
}
}
print(vec);
return 0;
}
void print(std::vector
{
std::cout<<"vector size is: "<
while(p != v.end())
{
std::cout<<*p<
}
}