65,186
社区成员




#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<string> vec1;
vec1.push_back("a");
vec1.push_back("b");
vector<string>::iterator it;
for(it=vec1.begin();it!=vec1.end();it++)
{
cout<<*it<<endl;
}
it=find(vec1.begin(),vec1.end(),"a");
if(it!=vec1.end())
{
cout<<"find"<<endl;
}
else
{
cout<<"not found"<<endl;
}
return 0;
}
Typename关键字 告诉编译器把一个特殊的名字解释成一个类型
constIterator=vetor.begin();//vector.begin()returns an iterator to the beginning of the vector