【c++基础】vector初始化的几种方式
前言
STL中的vector有几种初始化方式,根据不同的需求选择合适的初始化方式。
源码
// constructing vectors
#include <iostream>
#include <vector> int main ()
{
// constructors used in the same order as described above:
std::vector<int> first; // empty vector of ints
std::vector<int> second (,); // four ints with value 100
std::vector<int> third (second.begin(),second.end()); // iterating through second
std::vector<int> fourth (third); // a copy of third // the iterator constructor can also be used to construct from arrays:
int myints[] = {,,,};
std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) ); std::cout << "The contents of fifth are:";
for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n'; return ;
}
参考
1.cplusplus.com-vector-construct;
完
【c++基础】vector初始化的几种方式的更多相关文章
- vector初始化的几种方式-STL
vector<int>::iterator int_ite; vector<string>::iterator string_ite; //vector<T> ...
- easyUI 初始化的两种方式
easyUI 初始化的两种方式: class方式和js方式: <!DOCTYPE html> <html lang="en"> <head> & ...
- 使用GoldenGate初始化的两种方式
在使用OGG开始增量数据的实时复制之前,一般需要对当前的存量数据进行初始化,如果是同构数据库,则可以使用数据库自带的工具完成,比如Oracle DB中的rman, expdp/impdp等. 其实og ...
- JavaScript 基础——使用js的三种方式,js中的变量,js中的输出语句,js中的运算符;js中的分支结构
JavaScript 1.是什么:基于浏览器 基于(面向)对象 事件驱动 脚本语言 2.作用:表单验证,减轻服务器压力 添加野面动画效果 动态更改页面内容 Ajax网络请求 () 3.组成部分:ECM ...
- WebApplicationContext初始化的两种方式和获取的三种方式
原博客地址:http://blog.csdn.net/lmb55/article/details/50510547 接下来以ContextLoaderListener为例,分析它到底做了什么? app ...
- java基础之 创建对象的几种方式
有4种显式地创建对象的方式: 1.用new语句创建对象,这是最常用的创建对象的方式. 2.运用反射手段,调用java.lang.Class或者java.lang.reflect.Constructor ...
- java数组初始化的三种方式
//第一种 int[] is= new int[3]; is[0]=1; is[1]=2; is[2]=3; //第二种 int[] is2= {1,2,3}; //第三种 int[] is3= ...
- java中String初始化的两种方式
转自:http://www.diybl.com/course/3_program/java/javajs/2007104/75886.html 字符串可能是任何程序语言中都会出现的对象,j ...
- jquery初始化的三种方式
第一种 $(document).ready(function(){ alert("第一种方法."); }); 第二种 $(function(){ alert("第二种方法 ...
随机推荐
- [原]设置vs的release版本调试
通过三步设置就可以实现realse下的调试啦: 1.设置“C/C++”------>“常规”------->“调试信息格式”设置成:“程序数据库(/Zi)” 2.设置“链接器”------ ...
- URAL 1303 Minimal Coverage
URAL 1303 思路: dp+贪心,然后记录路径 mx[i]表示从i开始最大可以到的位置 sufmx[i]表从1-i的某个位置开始最大可以到达的位置 比普通的贪心效率要高很多 代码: #inclu ...
- CodeSmith无法获取Oracle表注释
如题:安装CodeSmith5.2版本,SQLServer没有任何问题,而Oracle就只能获取列的注释而不能获取表的注释,经过多方面查找资料后找到了一个最重要的解决方案,Sql语句,如下:selec ...
- python通过get方式,post方式发送http请求和接收http响应-urllib urllib2
python通过get方式,post方式发送http请求和接收http响应-- import urllib模块,urllib2模块, httplib模块 http://blog.163.com/xyc ...
- 清空mailq 队列里面的邮件
tmp_=`mailq | grep -E "root" | awk '{print $1}'` for i in $tmp_;do postsuper -d $i;done po ...
- git log 查找
查找含有某个字符串的 commit git log --grep=224 // 这条命令是查看含有 "224" 关键字的 git commit 查看某个作者 git log --a ...
- php表单提交安全方法
1.$_SERVER["PHP_SELF"] 将表单数据发送到页面本身,而不是跳转到另一张页面.这样,用户就能够在表单页面获得错误提示信息.2.通过使用 htmlspecialch ...
- HDU1789时间贪心
Doing Homework again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- WebService学习总结(转)
原文地址: WebService学习总结(一)——WebService的相关概念 WebService学习总结(二)——WebService相关概念介绍 WebService学习总结(三)——使用JD ...
- OC Foundation框架—字符串
一.Foundation框架中一些常用的类 字符串型: NSString:不可变字符串 NSMutableString:可变字符串 集合型: 1) NSArray:OC不可变数组 NSMutableA ...