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

4.6 建议

[1] 直接用代码表达思想;4.1节;[CG:P.1]。

[2] 具体类型是最简单的类。只要可能,优先选择具体类型而非复杂类或普通数据结构;4.2节;[CG:C.10]。

[3] 使用具体类表示简单概念;4.2节。

[4] 对于性能关键的组件,优先选择具体类而非类层次;4.2节。

[5] 定义构造函数来处理对象的初始化;4.2.1节、5.1.1节;[CG:C.40][CG:C.41]。

[6] 只有当函数需要直接访问类的表示时,才将其定义为成员;4.2.1节;[CG:C.4]。

[7] 定义运算符主要模仿其常规用法;4.2.1节;[CG:C.160]。

[8] 使用非成员函数定义对称运算符;4.2.1节;[CG:C.161]。

[9] 如果成员函数不改变其对象的状态,将其声明为const的;4.2.1节。

[10] 如果构造函数获取了资源,那么这个类就需要一个析构函数来释放这些资源;4.2.2节;[CG:C.20]。

[11] 避免使用“裸”new和delete操作;4.2.2节;[CG:R.11]。

[12] 使用资源句柄和RAII管理资源;4.2.2节;[CG:R.1]。

[13] 如果类是一个容器,为它定义一个初始化值列表构造函数;4.2.3节;[CG:C.103]。

[14] 如果需要将接口和实现完全分离开来,则使用抽象类作为接口;4.3节;[CG:C.122]。

[15] 使用指针和引用访问多态对象;4.3节。

[16] 抽象类通常不需要构造函数;4.3节;[CG:C.126]。

[17] 使用类层次表示具有继承层次结构的一组概念;4.5节。

[18] 具有虚函数的类应该同时具有一个虚的析构函数;4.5节;[CG:C.127]。

[19] 在规模较大的类层次中使用override显式地指明函数覆盖;4.5.1节;[CG:C.128]。 ...

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