vector的第四种初始化演示
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int main()
{
int arr[10] = {12,34,566,45,64,9,45,98,35,2};
char *str = "Hello vector!";
vector <int> vector1(arr, arr+10);
vector <char> vector2(str, str+strlen(str));
cout<<"vector1:"<<endl;
for(vector<int>::iterator p=vector1.begin(); p!=vector1.end(); ++p)
{
cout<<*p<<"";
}
cout<<endl<<"vector2:"<<endl;
for(vector<char>::iterator p1=vector2.begin(); p1!=vector2.end(); ++p1)
{
cout<<*p1;
}
cout<<endl;
return 0;
}
posted on 2011-11-23 10:11 More study needed. 阅读(224) 评论(0) 编辑 收藏 举报