Skip to Content
C++语言导学(原书第2版)
book

C++语言导学(原书第2版)

by 本贾尼 斯特劳斯特鲁普
August 2021
Intermediate to advanced
450 pages
5h 35m
Chinese
Pearson
Content preview from C++语言导学(原书第2版)

11.7 建议

[1] 一个标准库容器定义了一个序列;11.2节。

[2] 标准库容器是资源管理器;11.2节、11.3节、11.4节和11.5节。

[3] 将vector作为你的默认容器;11.2节和11.6节;[CG:SL.con.2]。

[4] 对于简单的容器遍历,使用范围for循环或一对首/尾迭代器;11.2节和11.3节。

[5] 使用reverse()避免指向元素的指针或迭代器失效;11.2节。

[6] 在未经过测试的情况下,不要假定使用reverse()会带来性能收益;11.2节。

[7] 使用容器及其push_back()和resize()操作,而不是使用数组和realloc()操作;11.2节。

[8] 调整vector大小后,不要再使用旧迭代器;11.2节。

[9] 不要假定[]有范围检查功能;11.2节。

[10] 如果你需要确保进行范围检查,应使用at()操作;11.2节;[CG:SL.con.3]。

[11] 使用范围for和标准库算法避免越界错误且不必付出代价;11.2.2节。

[12] 向容器插入元素时,元素是被拷贝进容器的;11.2.1节。

[13] 如要保持元素的多态行为,在容器中保存指针而非对象;11.2.1节。

[14] 在vector上执行插入操作,如insert()和push_back(),通常会异常高效;11.3节。

[15] 对通常为空的序列,使用forward_list;11.6节。

[16] 当事关性能,不要相信你的直觉,应进行性能测试;11.2节。

[17] map通常用红黑树实现;11.4节。

[18] unordered_map是哈希表;11.5节。

[19] 传递容器参数时,应传递引用,返回容器时,应返回值;11.2节。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

软件开发实践:项目驱动式的Java开发指南

软件开发实践:项目驱动式的Java开发指南

Raoul-Gabriel Urma, Richard Warburton
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu

Publisher Resources

ISBN: 9787111633280