书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

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.  阅读(226)  评论(0编辑  收藏  举报

导航

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!