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版)

1.10 建议

本章的建议是《C++Core Guidelines》[Stroustrup,2015]中的建议的一个子集。对那本书的引用是这种形式[CG:ES.23],意为“Expressions and Statement”一节中的第23条准则。一般地,每条核心准则都进一步给出了原理阐述和示例。

[1] 不必慌张!随着时间推移一切都会清晰起来;1.1节;[CG:In.0]。

[2] 不要排他地、单独地使用内置特性。正相反,最佳的方式通常是通过库(例如ISO C++标准库,参见第8~15章)间接地使用基本(内置)特性;[CG:P.10]。

[3] 要想写出好的程序,你不必了解C++的所有细节。

[4] 请关注编程技术,而非语言特性。

[5] 关于语言定义问题的最终结论,尽在ISO C++标准;16.1.3节;[CG:P.2]。

[6] 把有意义的操作“打包”成函数,并给它起个好名字;1.3节;[CG:F.1]。

[7] 一个函数最好只执行单一逻辑操作;1.3节;[CG:F.2]。

[8] 保持函数简洁;1.3节;[CG:F.3]。

[9] 当几个函数对不同类型执行概念上相同的任务时,使用重载;1.3节。

[10] 如果一个函数可能需要在编译时求值,那么将它声明为constexpr;1.6节;[CG:F.4]。

[11] 理解语言原语是如何映射到硬件的;1.4节、1.7节、1.9节、2.3节、4.2.2节、4.4节。

[12] 使用数字分隔符令大的字面值更可读;1.4节;[CG:NL.11]。

[13] 避免复杂表达式;[CG:ES.40]。

[14] 避免收缩转换;1.4.2节;[CG:ES.46]。

[15] 最小化变量的作用域;1.5节。

[16] 避免使用“魔法常量”,尽量使用符号化的常量;1.6节;[CG:ES.45]。 ...

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