#include<vector>
using std::vector; //Vector is a container.
//It has a collection of same type objects. //******************************************************
//Defining and Initializing vectors
vector<int> ivec; //Initially empty
//give ivec some values
vector<int> ivec2(ivec); //copy elements from ivec to ivec2
vector<int> ivec3 = ivec2; //The same as above. //In C++11
vector<int> ivec4 = {1,2,3,4}; //List initializing a vector
vector<int> ivec5{1,2,3,4}; vector<int> ivec6(10, -1); //ten int elements, each initialized to -1
//vector<Type> var(count, value); vector<int> ivec7(10); //10 elements, each initialized to 0
//vector<Type> v(n); v has n copies of a value-initialized object. //******************************************************
//Adding elements to a vector
ivec.push_back(1);
//****************************************************** //other operations
v.empty();
v.size();
//return the number of objects in v. The type of return value is not int, but vector<Type>::size_type.
v[n]; //just like the usage in array.
v1 = v2; //Replaces the elements in v1 with a copy of v2.
v1 == v2; //if v1 and v2 have the same objects, True
<, <=, >, >=//just like the compare in string

  

[Cpp primer] Library vector Type的更多相关文章

  1. [Cpp primer] Library string Type

    In order to use string type, we need to include the following code #include<string> using std: ...

  2. Library vector Type

    vector的定义 vector是C++标准库里最常用的容器,它之所以被称为容器,是因为它可以存放多个对象,所有在用一个容器中的对象都应该具有相同的类型. vector也是一个类模板,这也是它能存放多 ...

  3. Library string Type

    The string type supports variable-length character strings.The library takes cares of managing memor ...

  4. load_library(linker.cpp:759): library "libmaliinstr.so" not found

    1.02-07 15:19:09.277: E/linker(16043): load_library(linker.cpp:759): library "libmaliinstr.so&q ...

  5. Library string type(2)——关于String的操作

    关于string的定义,请参阅博文http://blog.csdn.net/larry233/article/details/51483827 string的操作 s.empty() //Return ...

  6. [Cpp primer] range for (c++11)

    for (declaration : expression) statement; /* This statement will iterate through the elements in the ...

  7. [Cpp primer] Namespace using Declarations

    If we want to use cin in the standard library, we need to std::cin To simplify this work, we can do ...

  8. qt+opencv LNK4272:library machine type 'x64' conflicts with target mathine type 'x86'

    运行时报错如上图所示,原因是你使用的opencv库是64位的,qt里面使用的编译器MSVC是32位的,解决方法如下: 将构建套件修改位64bit:

  9. C++primer学习笔记(一)——Chapter 3

    3.1 Namespace using Declarations 1.因为C++里有名字空间的定义,例如我们使用cin的时候必须写成std::cin,如果就用一次还是可以接受的,但是如果一直都这样,那 ...

随机推荐

  1. 【转】Ubuntu16.04安装WPS

    下载安装下载WPS For Linux:http://community.wps.cn/download/ 直接下载:http://kdl.cc.ksosoft.com/wps-community/d ...

  2. python全局替换文件内容脚本第1版

    #!/usr/bin/python #coding=utf8 """ # Author: xiaoyafei # Created Time : 2018-05-08 09 ...

  3. Linux服务器运行环境搭建(三)——MySQL数据库安装

    官网:http://www.mysql.com/ 官网下载地址:http://dev.mysql.com/downloads/mysql/ 说明:官网下载页面的“Select Platform” 选择 ...

  4. 从VS2010跳跃到VS2017

    Visual Studio 配色方案 https://studiostyl.es/ C#语言新特性 C#4.0:http://www.cnblogs.com/yangqi/archive/2010/0 ...

  5. Eclipse web工程 部署 三种方式 2

    Eclipse web工程 部署 三种方式 2.插件 tomcat插件下载: http://www.eclipsetotale.com/tomcatPlugin.html 解压缩后, com.sysd ...

  6. 添加删除表格(js完成)【自己实际项目】

    // 通过dom对象完成 注释掉了 /** function insertRows(){ var tempRow=0; var tbl=document.getElementById("di ...

  7. div横排放置对齐问题;block,inline,inline-block区别

    1.左右两个div都设置为float:left,如果右边div没有设置宽度,右边div的宽度会根据div里的内容自动调整. 缺点:不易控制 2.只有左侧div设置为float:left,右侧div设置 ...

  8. Docker学习(二)docker镜像操作

    上一篇:docker学习(一)在centos7上安装docker 列出所有docker镜像 docker images 拉取镜像 docker pull 镜像名 我这里一Tomact为例 首先在Doc ...

  9. BZOJ1690 Usaco2007 Dec 奶牛的旅行 【01分数规划】

    BZOJ1690 Usaco2007 Dec 奶牛的旅行 题目描述 作为对奶牛们辛勤工作的回报,Farmer John决定带她们去附近的大城市玩一天.旅行的前夜,奶牛们在兴奋地讨论如何最好地享受这难得 ...

  10. maven的介绍以及使用

    maven的介绍以及使用 1.什么是maven maven是一个项目管理工具,一个依赖管理系统,maven通过项目对象模型来管理jar包(POM.xml文件) 2.maven的优点 1.maven使用 ...