C++STL小白学习笔记(一)——STL概述

本文介绍了C++ Standard Template Library (STL),包括其主要组成部分:容器、迭代器和算法。通过示例展示了如何使用容器vector,并详细解释了迭代器的特性。此外,还提到了sort等算法的使用方法。
摘要由CSDN通过智能技术生成

使用STL的理由:

/+
* Reasons to use C++ standard library :
* 1. Code reuse, no need to re- invent the wheel.
* 2. Efficiency (fast and use less resources)。Modern C++ compiler are usually tuned to optimize for C++ s tandard library code .
* 3. Accurate, less buggy .
* 4. Terse, readable code; reduced control f1ow .
* 5. Standardization, guarenteed availability
* 6. A role model of writing library .
* 7. Good knowledge of data structures and algori thms .
*/

概述

STL全称为Standard Templates Library,即标准模板库,它是C++标准库的一个子集,主要包含三大部分:

Containers (容器)和Algorithms(算法)以及 Iterators(迭代器);

迭代器的出现是为了让两者更好地结合,
下面我们来看一个简单的STL示例:

示例:

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){

//Container:vector
	vector&l
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值