#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. CUDA Samples: heat conduction(模拟热传导)

    以下CUDA sample是分别用C++和CUDA实现的模拟热传导生成的图像,并对其中使用到的CUDA函数进行了解说,code参考了<GPU高性能编程CUDA实战>一书的第七章,各个文件内 ...

  2. Why ZK

    ZooKeeper是一个开放源代码的分布式协调服务,由知名互联网公司雅虎创建,是Google Chubby的开源实现.ZooKeeper的设计目标是将那些复杂且容易出错的分布式一致性服务封装起来,构成 ...

  3. Android 贝塞尔曲线解析

    相信很多同学都知道"贝塞尔曲线"这个词,我们在很多地方都能经常看到.利用"贝塞尔曲线"可以做出很多好看的UI效果,本篇博客就让我们一起学习"贝塞尔曲线 ...

  4. css实现加载中的效果

    那天闲着,学习了一下样式效果,自己实现了一个简单的加载中的效果 废话不多说,开始吧!! 一.实现一个圆环       要实现圆环,首先我们需要知道盒模型里面border的本质,先来看一个效果吧 从上面 ...

  5. Webdynpro ABAP 简单剖析

    众所周知,WEBDYNPRO是今天来SAP主推的一个面向WEB的MVC编程框架,接触过J2EE的朋友都不会对MVC这种设计模式陌生,WEBDYNPRO ABAP的基本设计思路和很多著名的面向互联网的M ...

  6. Android编程 EditView 中如何设置最多可以输入的字符数量 属性 android:ems 与 android:maxLength 的区别

    最近有一个新的感悟,那就是工作的时候千万不要遇到那种特要人无语的领导,很不幸我现在就遇到了这样的一个领导,说是要给领导认识的一个熟人家的孩子写本科毕业设计预算把我给派过去给本科生写毕业设计,这事情的确 ...

  7. Android Kill Process

    /********************************************************************** * Android Kill Process * 说明: ...

  8. Linux usleep for shell

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

  9. Hello Pythoner!

    首先,欢迎你来到pyer的博客,希望你能有所收获! 然后,pyer之前学C#(原博客地址:初行-博客园),后来转的Python,目前从事服务端研发工作. 最后,相逢便是缘,如果看过pyer的博客后有什 ...

  10. 通过以太坊发行代币(token)

    2017年开始,区块链ICO项目层出不穷,市场热度一波更胜一波,很多ICO都是通过以太坊智能合约发行自己的代币(token),具体怎样才能发行代币呢?本文进行具体详细的介绍. 准备工作 以太坊官网ER ...