#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. 开源一款资源分享与下载工具 —— 电驴(eMule)

    这里分享一款资源分享与下载工具--电驴,其实严格来说,应该叫电骡,这是我维护的版本,eMuleVeryCD版本,VeryCD是一个不错的资源分享网站:http://www.verycd.com/.大概 ...

  2. SQL 添加删除列

    --添加一列 alter table TableName add columnName columnType --删除表中的一列 alter table TableName drop column c ...

  3. Linux usleep for shell

    /**************************************************************************** * Linux usleep for she ...

  4. 【剑指offer】04A二维数组中的查找,C++实现

    1.题目 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数数组和一个整数,判断数组中是否含有该整数. 2.思路 首先选取数 ...

  5. Ubuntu12.04中安装Oracle JDK和NetBeans的方法

    1.到官网下载jdk-7u51-linux-i586.tar.gz安装包 2.创建jvm文件夹 $sudo mkdir /usr/lib/jvm 3.将安装包解压到上述文件夹下 $-linux-i58 ...

  6. springmvc+mybatis+redis实现查询插入操作

    最近在学习redis,虽然现在还不是很熟练.不过可以进行简单的框架整合开发. IDE:我使用的是IDEA.springmvc+spring+mybatis的整合这个我就不多说了,下面我们先进行这块的整 ...

  7. [Scala函数特性系列]——按名称传递参数

    通常情况下,函数的参数是传值参数:即参数的值在它被传递给函数之前被确定.但是,如果我们需要编写一个接收参数不希望马上计算,直到调用函数内的表达式才进行真正的计算的函数.对于这种情况,Scala提供按名 ...

  8. json对象和json字符串相互转换

    1.将JSON字符串转换为JSON对象 var data = JSON.parse(str); // JSON.parse();方法 console.log(data.name); 2.将JSON对象 ...

  9. svn 操作命令

    1.第一次提交代码到svn svn import project_directory PATH 2.将文件checkout到本地svn checkout path(path是服务器上的目录) 例如:s ...

  10. __all__ 作用, 相当于导入*

    它是一个string元素组成的list变量,定义了当你使用 from <module> import * 导入某个模块的时候能导出的符号(这里代表变量,函数,类等) 参考文章: http: ...