使用数组初始化vector
2015-09-04 10:29
447 查看
#include<iostream>
using namespace std;
int main()
{
int a[]={0,1,2,3,4,5};
vector<int> t(a,a+6);
for(vector<int>::iterator i = t.begin(); i!= t.end(); ++i)
{
cout<<*i<<endl;
}
return 0;
}
=====================================================
vector 有一构造函数形式如下:
template< class InputIt >
vector( InputIt first, InputIt last,
const Allocator& alloc = Allocator() );
故可以使用两个iterator 或者两个指针来初始化vector, vector
的内容为first(包括) 到last 前一个元素
using namespace std;
int main()
{
int a[]={0,1,2,3,4,5};
vector<int> t(a,a+6);
for(vector<int>::iterator i = t.begin(); i!= t.end(); ++i)
{
cout<<*i<<endl;
}
return 0;
}
=====================================================
vector 有一构造函数形式如下:
template< class InputIt >
vector( InputIt first, InputIt last,
const Allocator& alloc = Allocator() );
故可以使用两个iterator 或者两个指针来初始化vector, vector
的内容为first(包括) 到last 前一个元素
相关文章推荐
- spring 配置文件 常使用的命名空间
- 栈和堆的区别
- vs2013 编译的时候遇到的一个问题
- Mysql和Oracle中的分页机制
- C++ Primer : 第十三章 : 动态内存管理类
- HDU 4912(Paths on the tree-树上取链,贪心)
- CCM - 极致发挥STM32F4性能的利器
- C#在结构体的定义中又包含另一个结构体的数组
- 我是菜鸟:ForkJoin框架
- 日经春秋 20150904
- 在.net中序列化读写xml方法的总结
- HDU 4497 GCD and LCM(分解质因子+排列组合)
- android之VideoView和视频播放View的扩展
- 天声人語 20150904
- PAT(B) 1026. 程序运行时间
- (统计查询)一句sql统计多个状态的
- Nqueen1.0
- Hello JSP!——<jsp:include>动作元素篇
- 如何在现有的项目中使用CUDA
- C++RemoveReference