代码如下:
#include <iostream>
#include <vector>
#include <string>
using std::vector;
using std::string;
using std::cout;
int _tmain(int argc, _TCHAR* argv[])
{
string s[6] = { "pear", "apple", "peach", "grape", "kiwifruit", "ashis" };
vector<string> vs(s, s + 6);
for (vector<string>::iterator iter = vs.begin(); iter != vs.end();)
{
if ((*iter)[0] == 'a' || (*iter)[0] == 'A')
{
iter = vs.erase(iter);
}
else
{
iter++;
}
}
return 0;
}