更多参考其他文档菜鸟文档W3C微软C++文档

标准模板库STL(一)

string类

image-20210516144552809

image-20210516144840422

image-20210516144910561

image-20210516144925600

image-20210516144951476

image-20210516145019165

image-20210516145140880

image-20210516145222043

image-20210516145241848

image-20210516145333373

超出就数到最后一个字符为止

image-20210516145434670

image-20210516145444181

image-20210516145521398

image-20210516145547893

image-20210516145643266

image-20210516145714213

image-20210516145746657 image-20210516145805184

image-20210516145848123

image-20210516145857427

image-20210516145932375

需要用char* 和string类兼容

image-20210516150055641

image-20210516150112714

image-20210516150325202

泛型程序设计

  • image-20210516150538058

    image-20210516150558844

    image-20210516150657124

image-20210516150845854

image-20210516150855926

image-20210516150954409

image-20210516151020503

image-20210516151348281

image-20210516151728200

image-20210516151831815

image-20210516152106142

image-20210516152142367

image-20210516152247266

image-20210516152304270

image-20210516152617764

迭代器

  • image-20210518191736591

  • image-20210518191802641

  • 不可把迭代器与void*和“基类指针”混淆:指针代表真正的内存地址,即对象在内存中的存储位置;迭代器则代表元素在容器中的相对位置。

  • image-20210518192103344

    image-20210518192128595

  • image-20210518192257910

    image-20210518192448400

  • image-20210518192507711

  • image-20210518192658440

  • image-20210518192823441

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int N = 4;
int main()
{
vector<int> v;
vector<int>::const_iterator i; //迭代器 获取地址的指针
for (int i = N; i > 0; i--)
{
v.push_back(i);
}
i = v.begin();
cin >> v.front();
cout << *v.begin();
for (i = v.begin(); i < v.end(); ++i)
{
cout << "," << *i ;
}
cout <<endl;
}

算法

  • image-20210518192930818

  • image-20210518193126970

  • image-20210518193806467

    image-20210518193921618

  • image-20210519202736033

  • image-20210519202850307

  • image-20210519203132174

    image-20210519203209700

    image-20210519203409439

vector deque 和list

  • vector函数 查看文档

  • image-20210519204233296

  • deque

  • image-20210519204336859

  • list

  • image-20210519204500309

函数对象

  • image-20210519205337196

  • image-20210519205406795

    image-20210519205502571

  • image-20210519205620709

    image-20210519205638734

    image-20210519205721437

  • image-20210519210115666

  • image-20210519210532372

  • image-20210519210556422

  • image-20210519210712188

    image-20210519210755664

    image-20210519210819827

  • image-20210519211038880

  • image-20210519211108841

  • image-20210519211258806