Team LiB
Previous Section Next Section

Structure of This Book

本书结构

C++ Primer provides an introduction to the International Standard on C++, covering both the language proper and the extensive library that is part of that standard. Much of the power of C++ comes from its support for programming with abstractions. Learning to program effectively in C++ requires more than learning new syntax and semantics. Our focus is on how to use the features of C++ to write programs that are safe, that can be built quickly, and yet offer performance comparable to the sorts of low-level programs often written in C.

本介绍了 C++ 国际标准,既涵盖语言的特征,又讲述了也是标准组成部分的丰富标准库。C++ 的强大很大程度上来自它支持抽象程序设计。要学会用 C++ 高效地编程,只是掌握句法和语义是远远不够的。我们的重点在于,教会读者怎样利用 C++ 的特性,快速地写出安全的而且性能可与 C 语言低层程序相媲美的程序。

C++ is a large language and can be daunting to new users. Modern C++ can be thought of as comprising three parts:

C++ 是一种大型的编程语言,这可能会吓倒一些新手。现代 C++ 可以看成由以下三部分组成:

  • The low-level language, largely inherited from C

    低级语言,多半继承自 C。

  • More advanced language features that allow us to define our own data types and to organize large-scale programs and systems

    更高级的语言特征,用户可以借此定义自己的数据类型,组织大规模的程序和系统。

  • The standard library, which uses these advanced features to provide a set of useful data structures and algorithms

    标准库,使用上述高级特征提供一整套有用的数据结构和算法。

Most texts present C++ in this same order: They start by covering the low-level details and then introduce the the more advanced language features. They explain the standard library only after having covered the entire language. The result, all too often, is that readers get bogged down in issues of low-level programming or the complexities of writing type definitions and never really understand the power of programming in a more abstract way. Needless to say, readers also often do not learn enough to build their own abstractions.

多数 C++ 教材按照下面的顺序展开:先讲低级细节,再介绍更高级的语言特征;在讲完整个语言后才开始解释标准库。结果往往使读者纠缠于低级的程序设计问题和复杂类型定义的编写等细节,而不能真正领会抽象编程的强大,更不用说学到足够的知识去创建自己的抽象了。

In this edition we take a completely different tack. We start by covering the basics of the language and the library together. Doing so allows you, the reader, to write significant programs. Only after a thorough grounding in using the library and writing the kinds of abstract programs that the libary allowsdo we move on to those features of C++ that will enable you to write your own abstractions.

本版中我们独辟蹊径。一开始就讲述语言的基础知识和标准库,这样读者就可以写出比较大的有实际意义的程序来。透彻阐释了使用标准库(并且用标准库编写了各种抽象程序)的基础知识之后,我们才进入下一步,学习用 C++ 的其他高级特征来编写自己的抽象。

Parts I and II cover the basic language and library facilities. The focus of these parts is to learn how to write C++ programs and how to use the abstractions from the library. Most C++ programmers need to know essentially everything covered in this portion of the book.

第一第二部分讨论语言的基础知识和标准库设施。其重点在于学会如何编写 C++ 程序,如何使用标准库提供的抽象设施。大部分 C++ 程序员需要了解本书这两部分的内容。

In addition to teaching the basics of C++, the material in Parts I and II serves another important purpose. The library facilities are themselves abstract data types written in C++. The library can be defined using the same class-construction features that are available to any C++ programmer. Our experience in teaching C++ is that by first using well-designed abstract types, readers find it easier to understand how to build their own types.

除了讲解基础知识以外,这两部分还有另外一个重要的意图。标准库设施本身是用 C++ 编写的抽象数据类型,定义标准库使用的是任何 C++ 程序员都能使用的构造类的语言特征。我们教授 C++ 的经验说明,一开始就使用设计良好的抽象类型,读者会更容易理解如何建立自己的类型。

Parts III through V focus on how we can write our own types. Part III introduces the heart of C++: its support for classes. The class mechanism provides the basis for writing our own abstractions. Classes are also the foundation for object-oriented and generic programming, which we cover in Part IV. The Primer concludes with Part V, which covers advanced features that are of most use in structuring large, complex systems.

第三第五部分着重讨论如何编写自己的类型。第三部分介绍 C++ 的核心,即对类的支持。类机制提供了编写自定义抽象的基础。类也是第四部分中讨论的面向对象编程和泛型编程的基础。全书正文的最后是第五部分,这一部分讨论了一些高级特征,它们在构建大型复杂系统时最为常用。

Team LiB
Previous Section Next Section