随笔分类 - STL
摘要:5. vector容器 vector容器与数组非常相似,也称为单端数组。不同之处在于,数组是静态空间,而vector可以动态拓展。其中动态拓展并不是在原空间之后续接新空间,而是找更大的内存空间,然后将原数据拷贝至新空间,释放原空间。 vector容器的迭代器是支持随机访问的迭代器。 vector的构
阅读全文
摘要:4. string容器 构造函数 //默认构造 string s1; // 使用字符串str初始化 const char* str = "hello world"; string s2(str); // 使用一个string对象初始化另一个string对象 const char* str2 = "6
阅读全文
摘要:3、 vector容器 存放内置数据类型 #include <iostream> #include <vector> #include <algorithm> using namespace std; void MyPrint(int value) { cout << value << " "; }
阅读全文
摘要:1、 STL的基本概念 STL (Standard Template Library,标准模板库) STL从广义上分为:容器(container)算法(algorithm)迭代器(iterator) 容器和算法之间通过迭代器进行无缝衔接 STL几乎所有的代码都采用了模板类和模板函数 STL的六大组件
阅读全文