Skip to Content
C++程序设计:原理与实践(基础篇)(原书第2版)
book

C++程序设计:原理与实践(基础篇)(原书第2版)

by 本贾尼 斯特劳斯特鲁普
August 2021
Intermediate to advanced
450 pages
9h 36m
Chinese
Pearson
Content preview from C++程序设计:原理与实践(基础篇)(原书第2版)

8.1 技术细节

如果可以选择的话,我们更愿意讨论程序设计,而不是程序设计语言的特性;也就是说,我们认为,如何用代码表达思想远比我们用来表达这些思想的程序设计语言技术细节更有意思。自然语言中有类似的情况:我们更愿意讨论一部好的小说中的思想和它表达这些思想的方式,而不会愿意研究其中的英语语法和词汇。总之,重要的是思想和如何用代码表达思想,而不是单独的编程语言特性。

但是,我们不是总能选择。当你开始编程时,你用的编程语言对你而言就是一门外语,你必须学习它的“语法和词汇表”,这就是本章和下一章要做的事情,但请不要忘记:

·我们要学习的主要是程序设计。

·我们生产的是程序和系统。

·程序设计语言(只)是工具。

记住这几点似乎极其困难,很多程序员对明显是属于编程语言语法和语义次要细节的内容表现出巨大的热情。特别是,很多人有这样一个错误观念:他们使用的第一种编程语言中的工作方法是做任何事的“不二法门”。请不要掉入这种陷阱。C++在很多方面是一种非常好的编程语言,但它并不完美,任何其他编程语言也都一样。

大多数程序设计概念是通用的,而很多这种概念被流行的程序设计语言所广泛支持。这意味着,我们在一门好的程序设计课中学到的基本思想和技术可以从一种编程语言延续到下一种语言。也就是说,它们可以(不同程度)方便地用于所有语言。而编程语言的技术细节则只限于特定的语言。幸运的是,编程语言不是凭空设计出来的,因此你在这里学到的很多内容都会在其他语言中找到明显的对应内容。特别是C++与C(第27章)、Java和C#属于同一类语言,它们具有相当多的共性。

注意,当我们讨论语言技术问题时,我们故意使用非描述性的命名,如f、g、X和y。我们这样做是为了强调这些例子的技术性质,保证这些例子很简短,以及尽力避免将语言技术细节和真正的程序设计方法混淆而令你困惑。当你看到非描述性的名字(例如那些永远不应该用在真实代码中的名字)时,请将注意力放在代码的语言技术层面上来。典型的语言技术实例仅仅包含用来展示语言规则的代码。如果你编译并运行这些代码,你会得到很多“变量未使用”的警告,而这样的技术性程序片段很少具有实用意义。 ...

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

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

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

本贾尼 斯特劳斯特鲁普
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
Python编程入门与实战

Python编程入门与实战

Posts & Telecom Press, Fabrizio Romano

Publisher Resources

ISBN: 9787111562252